You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicstaticInputValidationValidCustomFormula=delegate(stringval){if(String.IsNullOrWhiteSpace(val))return"";else{varexpr=new Expression(val);decimalx=5m;decimala=6m;decimalb=7m;
expr.Parameters["x"]=x;
expr.Parameters["a"]=a;
expr.Parameters["b"]=b;try{Func<float>f= expr.ToLambda<float>();// Here it throws System.ArgumentNullException. Parameter name: expressionfloatres= f();}catch(Exceptione){return"There was an error while parsing the custom formula: "+ e.Message;}}}varres= ValidCustomFormula("2 + 2 - a - b - x");
As long as I don't include any parameter in the expression itselt (i.e.: "2 + 2 + 2") it works, but it doesn't when I include some parameter. Am I missing something? Looks like a bug.
Thanks.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue. The Parameters dictionary was not supported by the lambda expression compiler. I added support for that, but notice that values contained in the Parameters dictionary become constants in the lambda expression. If you need the ability to change those values after compilation you should look into using an ExpressionContext as described in README.md.
Consider the following code:
As long as I don't include any parameter in the expression itselt (i.e.: "2 + 2 + 2") it works, but it doesn't when I include some parameter. Am I missing something? Looks like a bug.
Thanks.
The text was updated successfully, but these errors were encountered: