Invoke() public method

public Invoke ( IContext context, object @this, object arguments ) : object
context IContext
@this object
arguments object
return object
示例#1
0
        public void EvaluateWithThisObject()
        {
            Context context = new Context();
            ICommand body = new ReturnCommand(new ArithmeticBinaryExpression(ArithmeticOperator.Add, new VariableExpression("x"), new DotExpression(new VariableExpression("this"), "Age")));
            Function function = new Function(new string[] { "x" }, body);
            DynamicObject person = new DynamicObject();
            person.SetValue("Age", 30);

            Assert.AreEqual(40, function.Invoke(context, person, new object[] { 10 }));
        }
示例#2
0
        public void InvokeSimpleFunction()
        {
            ICommand body = new ReturnCommand(new VariableExpression("x"));
            Function function = new Function(new string[] { "x" }, body);

            Context context = new Context();
            context.SetValue("x", 2);

            object result = function.Invoke(context, null, new object[] { 1 });

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
        }