v2.7.1
Download the library here
- ADDED:
IsExpressionValueproperty to theVariableFactoryArgument. When true, a parameter will no longer be used from the value, the expression will be returned directly. This new option allows creating dictionary value on the fly.
var variables = new Dictionary<string, object>();
var eval = new EvalContext();
eval.VariableFactory = argument =>
{
variables[argument.Name] = 2;
argument.IsHandled = true;
argument.IsExpressionValue = true;
var dict = Expression.Constant(variables);
var dictionaryItemPropertyInfo = typeof(IDictionary).GetProperty("Item", new[] { typeof(string) });
Expression innerExpression = Expression.Property(dict, dictionaryItemPropertyInfo, Expression.Constant(argument.Name));
argument.Value = Expression.Convert(innerExpression, typeof(int));
};
eval.Execute("x = 0; x = 6 + x;", variables);
var value = variables["x"];
var counter = variables.Count;Trial unlocked for the current month (July)