A parametrized string library!



Strinken is focused on giving the possibility to the user of an application to easily change its configuration by using string interpolation. This is achieved by restricting the possible variables to a definite set (tags, filters, ...) that the user can see and only allowing this set. Thanks to this restriction, no reflection is needed and the string resolution is fast.

Installation


  • Grab the latest package on NuGet.

Basic example


1. 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();
}

2. Create a Parser<T> with this tag:

var parser = new Parser<Person>().WithTag(new NameTag());

3. Resolve a string with the parser:

var result = parser.Resolve("My name is {Name}.", new Person { Name = "James" }); // will return "My name is James."

For more complex examples with multiple tags, filters and parameter tags, see the usage section. The code of this example is here.