internal IScriptHost CreateScriptHost(IScriptEnvironment environment) { Debug.Assert(environment != null); #if FULL // a remote host was created by call to ScriptEnvironment.CreateRemote if (_remoteHost != null) { return(CreateLocalHost(_remoteHost)); } #endif // do not create forwarding host (single app-domain scenario): return(CreateHostLocally(environment)); }
/// <summary> /// /// </summary> private static void LoadScripts() { // 古いものをすべて削除 OnUnload(EventArgs.Empty); Unload = null; Load = null; #pragma warning disable 0618 DynamicHelpers.TopNamespace.LoadAssembly(Assembly.GetExecutingAssembly()); DynamicHelpers.TopNamespace.LoadAssembly(Assembly.LoadWithPartialName("System.Windows.Forms")); #pragma warning restore 0618 IScriptEnvironment scriptEnv = ScriptEnvironment.GetEnvironment(); _module = scriptEnv.CreateModule("ScriptModule"); Boolean hasScripts = false; if (Directory.Exists("Scripts")) { foreach (String path in Directory.GetFiles("Scripts", "*.py")) { Debug.WriteLine("Load Script: " + path); try { IScriptEngine engine = scriptEnv.GetLanguageProviderByFileExtension(Path.GetExtension(path)).GetEngine(); engine.ExecuteFileContent(path, _module); hasScripts = true; } catch (SyntaxErrorException se) { MessageBox.Show(String.Format(Resources.Strings.ScriptSyntaxException, path, se.Line, se.Column, se.Message), ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception e) { MessageBox.Show(String.Format(Resources.Strings.ScriptException, path, e.Message), ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } // 一つも読み込んでいなかったらデフォルト if (!hasScripts) { Script.GetEngine("py").Execute(Resources.Strings.DefaultPythonScript, _module); } // 実行 _module.Execute(); OnLoad(EventArgs.Empty); ShowBalloonTip(Resources.Strings.ScriptsLoaded, ToolTipIcon.Info); }
public Task <IRunResult> Run <T>(ClearScriptScript script, IScriptEnvironment <T> externalEnvironment) { //TODO: add checks for script context type, version and environment var runId = Guid.NewGuid().ToString(); var jintContext = externalEnvironment.Context; _engine.AddHostObject("context", jintContext); _engine.Execute(script.JavaScriptCode); return(Task.FromResult <IRunResult>(new ScriptExecutionSuccess() { Id = runId })); }
public Task <IRunResult> Run <T>(Script script, IScriptEnvironment <T> externalEnvironment) { //TODO: add checks for script context type, version and environment var runId = Guid.NewGuid().ToString(); var jintContext = externalEnvironment.Context; _engine.SetValue("context", jintContext); _engine.Execute(script.Code); var result = _engine.GetCompletionValue().ToObject(); return(Task.FromResult <IRunResult>(new ScriptExecutionSuccess() { Id = runId, Result = result })); }
public SilverlightScriptHost(IScriptEnvironment environment) : base(environment) { }
/// <exception cref="InvalidImplementationException">The host type failed to instantiate.</exception> internal ScriptHost CreateHostLocally(IScriptEnvironment environment) { Debug.Assert(environment != null); return ReflectionUtils.CreateInstance<ScriptHost>(_hostType, environment); }
internal IScriptHost CreateScriptHost(IScriptEnvironment environment) { Debug.Assert(environment != null); #if FULL // a remote host was created by call to ScriptEnvironment.CreateRemote if (_remoteHost != null) return CreateLocalHost(_remoteHost); #endif // do not create forwarding host (single app-domain scenario): return CreateHostLocally(environment); }
internal ScriptHost() { _environment = null; }
public ScriptHost(IScriptEnvironment environment) { Contract.RequiresNotNull(environment, "environment"); _environment = environment; _defaultModule = null; }
public SilverlightScriptHost (IScriptEnvironment environment) : base (environment) { }
/// <exception cref="InvalidImplementationException">The host type failed to instantiate.</exception> internal ScriptHost CreateHostLocally(IScriptEnvironment environment) { Debug.Assert(environment != null); return(ReflectionUtils.CreateInstance <ScriptHost>(_hostType, environment)); }