I am using Dynamic-Expresso library. I would like to evaluate expression containing foreach statement. Is that possible? The only way I can see is to write parametrized method and send the whole class as a parameter to the Interpreter
var target = new Interpreter();
target.SetVariable("a", a, typeof(Tools));
target.SetVariable("b", b, typeof(List<param>));
if (target.Eval("a.MethodWithForeach(b)").Equals(true))
{
...
}
You are right, for now there isn't an easy way to work with collections. I already have a plan to work on this feature but I don't known an exact release date.
For now, as a workaround, you can write some helpers like the one below:
Basically I have created a little helper to simulate some LINQ functions (
Where
in the above example). You can then call this helper from your expressions.