public override void InitPlugin() { var actions = RegisterScriptCommands(); scriptHost = new ScriptHost(actions, Logger, ExecuteScriptByName); scriptEvents = RegisterScriptEvents(Context.GetAllPlugins(), Logger); }
/// <summary> /// Запуск скрипта /// </summary> private static void ExecuteScript(UserScript script, ScriptHost scriptHost, Logger logger, object[] args) { //Debugger.Launch(); try { //var engine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging); var engine = new JScriptEngine(); engine.AddHostObject("host", scriptHost); string initArgsScript = string.Format("var arguments = {0};", args.ToJson("[]")); engine.Execute(initArgsScript); engine.Execute(script.Body); } catch (Exception ex) { var messge = string.Format("Error in user script {0}", script.Name); logger.Error(ex, messge); } }