There are no dependencies and it will run on any .NET platform, including iOS and Android (using Xamarin). The expression syntax is compatible with C# 2.0 (so no support for generics)
var context = new CSharpContext(); context["SomeString"] = "Hi there!"; context["SomeNumber"] = 20; var parser = new CSharpParser(); var result = parser.Evaluate<int>("SomeNumber + SomeString.Length", context); // returns 29
var context = new CSharpContext(); context.AddType("Math", typeof(Math)); context.Set("SomeString", "Hi there!"); context.Set("SomeNumber", 20); context.AddFunction("fmt", typeof(String), "Format"); var parser = new CSharpParser(); string stringValue = parser.Evaluate<string>("fmt(\"I said: {0}\", SomeString)", context); // returns "I said: Hi there!" int intValue = parser.Evaluate<int>("Math.Max(10, SomeNumber)" , context); // returns 20 double doubleValue = parser.Evaluate<double>("SomeNumber * 2.0", context); // returns 40.0
// create parser using double curly braces syntax var parser = new TemplateParser<DoubleCurly>(); var data = new { name = "John", age = 25 }; var s = parser.Render("My name is {{name}} and I'm {{age}} years old", data); // s == "My name is John and I'm 25 years old"