mparlak / Flee

Fast Lightweight Expression Evaluator
624 stars 119 forks source link

pass object to experssion #42

Closed Diaskhan closed 6 years ago

Diaskhan commented 6 years ago

1.Its possible to pass object and call there methods ?

obj1 = new Circle(5,5);
fle.variables.add(obj1) 
fle.eval("obj1.SomeMethod()");

2.Supporting anonymous types ?

dynamic MyDynamic = new System.Dynamic.ExpandoObject();
MyDynamic.A = "A";
MyDynamic.B = "B";
MyDynamic.C = "C";
MyDynamic.Number = 12;
MyDynamic.MyMethod = new Func<int>(() => 
{ 
    return 55; 
});
Console.WriteLine(MyDynamic.MyMethod());
piranout commented 6 years ago

`obj1 = new Circle(5,5);

fle.variables.add(obj1)

fle.eval("obj1.SomeMethod()");`

You can achieve #1 by setting obj1 as the expression owner—do this by passing it to the constructor of the expression evaluator.