Closed minikie closed 4 years ago
"Count" is a property of IList interface; there are no "Max" or "Min" properties there.
In C# code you can use values.Max()
or values.Min()
- but this is extension methods (in fact, static methods defined in System.Linq). Static methods cannot be used in LambdaParser.
If you need to calculate Min or Max you can provide these functions into the evaluation context:
varContext["myValues"] = new [] { 1, 5, 10 };
varContext["Min"] = (Func<IList,object>)((values) => {
// here is your code that returns 'max' value for generic IList input
});
Console.WriteLine(lambdaParser.Eval("Max(myValues)", varContext));
"Count" is a property of IList interface; there are no "Max" or "Min" properties there.
In C# code you can use
values.Max()
orvalues.Min()
- but this is extension methods (in fact, static methods defined in System.Linq). Static methods cannot be used in LambdaParser.If you need to calculate Min or Max you can provide these functions into the evaluation context:
varContext["myValues"] = new [] { 1, 5, 10 }; varContext["Min"] = (Func<IList,object>)((values) => { // here is your code that returns 'max' value for generic IList input }); Console.WriteLine(lambdaParser.Eval("Max(myValues)", varContext));
Thanks~!
Expression of "values.Count" is working. But values.Max or values.Min is not working... can you fix it?