public bool EvalExpressionNET(Parameter parameter) { using (Z.Expressions.EvalContext context = new Z.Expressions.EvalContext()) { context.UseLocalCache = true; List <int> results = new List <int>(parameter.Statements.Length); foreach (string statement in parameter.Statements) { int result = context.Execute <int>(statement); results.Add(result); } return(Assert(results, parameter.Sum)); } }
public bool EvalExpressionNET(Parameter parameter) { using (Z.Expressions.EvalContext context = new Z.Expressions.EvalContext()) { context.UseLocalCache = true; context.AliasLocalVariables["n"] = parameter.Numbers; List <int> results = new List <int>(parameter.Numbers.Length); foreach (int number in parameter.Numbers) { int result = context.Execute <int>(parameter.Statements[number]); results.Add(result); } return(Assert(results, parameter.Sum)); } }
public bool EvalExpressionNETCompiled(Parameter parameter) { using (Z.Expressions.EvalContext context = new Z.Expressions.EvalContext()) { context.UseLocalCache = true; Func <int, int> @delegate = context.Compile <Func <int, int> >(EXPRESSION, "n"); List <int> results = new List <int>(parameter.Numbers.Length); foreach (int number in parameter.Numbers) { int result = @delegate(number); results.Add(result); } return(Assert(results, parameter.Sum)); } }