Hello ifle,
Currently ClearScript doesn't have an API method like that. We'll add one in the next release. In the meantime, you can add an extension method that does what you want:
With this class in place, you can do this:
Cheers!
Currently ClearScript doesn't have an API method like that. We'll add one in the next release. In the meantime, you can add an extension method that does what you want:
publicstaticclass ScriptEngineExtensions { publicstaticobject InvokeFunction(this ScriptEngine engine, string name, object[] args) { var host = new HostFunctions(); ((IScriptableObject)host).OnExposedToScriptCode(engine); var del = (Delegate)host.func<object>(args.Length, engine.Script[name]); return del.DynamicInvoke(args); } }
engine.InvokeFunction("foo", newobject[] { 1, 2, 3 });