/// <summary> /// Invokes a method from the given object with the given arguments. /// </summary> /// <param name="method">The method's name</param> /// <param name="caller">The object from which to call a method</param> /// <param name="args">The arguments to pass to the method</param> /// <returns>The value returned by the method</returns> public static Dynamic Invoke(string method, Dynamic caller, params object[] args) { Expression callingExpr = new Literal(caller); var literals = new Expression[args.Length]; for (int i = 0; i < args.Length; ++i) { literals[i] = new Literal(DynamicFactory.CreateDynamic(args[i])); } var call = new MethodCall(callingExpr, method, literals); call.AcceptCompiler(Interpreter); return(Interpreter.ReturnedValue); }