Skip to content

k94ll13nn3/Strinken

Repository files navigation

Strinken

NuGet GitHub release GitHub license ci.yml

A parametrized string library! (Documentation)

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."