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
Methods
Get(string)
Gets a top-level string value by key.
Returns null if the key does not exist.
string? Get(string key)
Parameters
keystring
Returns
Get<T>(string)
Gets and deserialises a value by key.
Returns default if the key does not exist.
T? Get<T>(string key)
Parameters
keystring
Returns
- T
Type Parameters
TThe 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
Returns
- bool
trueif the key exists; otherwisefalse.