Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it is not support Convert #49

Open
DNetORM opened this issue Apr 17, 2024 · 1 comment
Open

it is not support Convert #49

DNetORM opened this issue Apr 17, 2024 · 1 comment
Labels

Comments

@DNetORM
Copy link

DNetORM commented Apr 17, 2024

var res = lambdaParser.Eval("Convert.ToInt32("111")", varContext)

this is not work well. how to support more system namespace class and functions?

@VitaliyMF
Copy link
Contributor

For security reasons it is not possible to call any static methods like "Convert.ToInt32"; only evaluation context that is available is defined explicitly (via variables). If you need to provide some 'API' that should be available in expressions you may use this approach:

class MathFunctions {
  public double Pow(double x, double y) => Math.Pow(x,y);
}

varContext["Math"] = new MathFunctions();
Console.WriteLine(lambdaParser.Eval("Math.Pow(2,2)", varContext));

(this can be Convert variable that holds an object that has ToInt32 method, for instance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants