Table of Contents

Interface ITemplateConfig

Namespace
HoofMark.CSharpTemplating.Abstractions
Assembly
HoofMark.CSharpTemplating.Abstractions.dll

Provides access to configuration values loaded from the template's sibling JSON file.

public interface ITemplateConfig

Remarks

Given a template file MyTemplate.cs, the engine looks for MyTemplate.json in the same directory. The JSON file should be a flat or nested object:

{
  "Namespace": "MyApp.Models",
  "ClassName": "OrderService",
  "Properties": [
    { "Name": "Id", "Type": "int" }
  ]
}

Properties

All

Raw access to all top-level values as JsonElements. Useful for iterating all keys or accessing deeply nested structures.

IReadOnlyDictionary<string, JsonElement> All { get; }

Property Value

IReadOnlyDictionary<string, JsonElement>

Methods

Get(string)

Gets a top-level string value by key. Returns null if the key does not exist.

string? Get(string key)

Parameters

key string

Returns

string

Get<T>(string)

Gets and deserialises a value by key. Returns default if the key does not exist.

T? Get<T>(string key)

Parameters

key string

Returns

T

Type Parameters

T

The type to deserialise the value into.

TryGet(string, out string?)

Tries to get a top-level string value by key.

bool TryGet(string key, out string? value)

Parameters

key string
value string

Returns

bool

true if the key exists; otherwise false.