public override int Execute() { var hostedScript = new HostedScriptEngine(); hostedScript.CustomConfig = ScriptFileHelper.CustomConfigPath(_path); hostedScript.Initialize(); ScriptFileHelper.OnBeforeScriptRead(hostedScript); var source = hostedScript.Loader.FromFile(_path); var compiler = hostedScript.GetCompilerService(); hostedScript.SetGlobalEnvironment(new DoNothingHost(), source); var writer = new ScriptEngine.Compiler.ModuleWriter(compiler); try { writer.Write(Console.Out, source); } catch (ScriptException e) { Output.WriteLine(e.Message); return(1); } return(0); }
public override int Execute() { var hostedScript = new HostedScriptEngine(); hostedScript.Initialize(); var source = hostedScript.Loader.FromFile(_path); var compiler = hostedScript.GetCompilerService(); var writer = new ScriptEngine.Compiler.ModuleWriter(compiler); writer.Write(Console.Out, source); return 0; }
public override int Execute() { var hostedScript = new HostedScriptEngine(); hostedScript.Initialize(); var source = hostedScript.Loader.FromFile(_path); var compiler = hostedScript.GetCompilerService(); var writer = new ScriptEngine.Compiler.ModuleWriter(compiler); writer.Write(Console.Out, source); return(0); }
private void Button_Click(object sender, RoutedEventArgs e) { var hostedScript = new HostedScriptEngine(); hostedScript.Initialize(); var src = hostedScript.Loader.FromString(txtCode.Text); using (var writer = new StringWriter()) { try { var moduleWriter = new ScriptEngine.Compiler.ModuleWriter(hostedScript.GetCompilerService()); moduleWriter.Write(writer, src); result.Text = writer.GetStringBuilder().ToString(); } catch (Exception exc) { result.Text = exc.Message; } } }