A parametrized string library! (Documentation)
- Grab the latest package on NuGet.
-
Create a class that implements
ITag<T>
for the wanted type (a class Person with a Name property for example):public class NameTag : ITag<Person> { public string Description => "Returns the name of a Person."; public string Name => "Name"; public string Resolve(Person value) => value.Name.ToString(); }
-
Create a
Parser<T>
with this tag:var parser = new Parser<Person>().WithTag(new NameTag());
-
Resolve a string with the parser:
var result = parser.Resolve("My name is {Name}.", new Person { Name = "James" }); // will return "My name is James."