/// <summary> /// Invokes a scripted function from user code. /// </summary> /// <param name="function">The name of the function to be invoked</param> /// <param name="args">Arguments to be passed to the function</param> /// <returns>The value returned by the function itself</returns> public Dynamic Invoke(string function, params object[] args) { 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 FunctionCall(function, literals); RuntimeServices.Interpreter = interpreter; call.AcceptCompiler(interpreter); return(interpreter.ReturnedValue); }