, :
NB #, VB.NET, ,
Lazy Parser
Lazy Parser .
: #, :
ParserContext context = new ParserContext();
context.AddType("Math", typeof(Math));
context.Set("SomeString", "Hi there!");
context.Set("SomeNumber", 20);
context.AddFunction("fmt", typeof(String), "Format");
CSharpParser parser = new CSharpParser();
string stringValue = parser.Evaluate<string>("fmt(\"I said: {0}\", SomeString)", context);
:
ExpressionContext context = new ExpressionContext();
context.Imports.AddType(typeof(Math));
context.Variables["a"] = 100;
IDynamicExpression eDynamic = context.CompileDynamic("sqrt(a) + pi");
IGenericExpression<double> eGeneric = context.CompileGeneric<double>("sqrt(a) + pi");
double result = (double)eDynamic.Evaluate();
result = eGeneric.Evaluate();
context.Variables["a"] = 144;
result = eGeneric.Evaluate();
:
LUA .NET