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
First of all, thank you for writing DynamicExpresso. It worked as claimed.
I am trying to do assignment. Right now I did the assignment using function call, which is less than ideal.
public class ObjectA { public object Value; }
public class ObjectB { public object Value; }
public void Test1()
{
var interpreter = new Interpreter();
var objA = new ObjectA();
var objB = new ObjectB();
var data = new Dictionary<string, dynamic>() {
{"a",objA},
{"b",objB},
};
var paramsList2 = pData.Select(r => new Parameter(r.Key, r.Value)).ToArray();
interpreter.Eval("a.Value = b.Value", paramsList2);
Debug.WriteLine(objA.Value);
Debug.WriteLine(objB.Value);
}
public void Test2()
{
var interpreter = new Interpreter();
var objA = new ObjectA();
var objB = new ObjectB();
var data = new Dictionary<string, dynamic>() {
{"a",objA},
{"b",objB},
};
//suppose I set all the SetFunction() here.
....
//Attempting to make Func and Action class working in string expression
interpreter.Reference(typeof(Func<bool>));
interpreter.Reference(typeof(Action));
var paramsList2 = pData.Select(r => new Parameter(r.Key, r.Value)).ToArray();
//The following won't work because => operator not supported
interpreter.Eval("new Func<bool>(() => { a.Value = b.Value; return true; })", paramsList2);
//The following won't work because it returns nothing, and => operator not supported
interpreter.Eval("new Action(() => { a.Value = b.Value; })", paramsList2);
//Works, but limited my possibility and flexibility
interpreter.Eval("SetVal(a,b)", paramsList2);
Debug.WriteLine(objA.Value);
Debug.WriteLine(objB.Value);
}
public bool SetVal(dynamic pa, dynamic pb)
{
pa.Value = pb.Value;
return true;
}
Thank you!
The text was updated successfully, but these errors were encountered:
First of all, thank you for writing DynamicExpresso. It worked as claimed.
I am trying to do assignment. Right now I did the assignment using function call, which is less than ideal.
Thank you!
The text was updated successfully, but these errors were encountered: