Ejemplo n.º 1
0
 public void runScript(string filename)
 {
     try
     {
         Console.WriteLine("Run Script " + scope);
         engine.CreateScriptSourceFromFile(filename).Execute(scope);
         Console.WriteLine("Run Script Done");
     }
     catch (Exception e)
     {
         if (OutputWriter != null)
         {
             OutputWriter.Write(engine.GetService <ExceptionOperations>().FormatException(e));
         }
         CustomMessageBox.Show("Error running script " + engine.GetService <ExceptionOperations>().FormatException(e));
     }
 }
Ejemplo n.º 2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            this.RootVisual = new MainPage();

            var runtime = Silverlight.DynamicEngine.CreateRuntime();
            _python = runtime.GetEngine("python");

            _scope = _python.CreateScope();
            _repl = Silverlight.Repl.Show(_python, _scope);
            _scope.SetVariable("app", this);

            try {
                test("Execute strings", "4", "2 + 2");
                test("Import .NET namespace", "hi", @"import System
            System.String('hi')");
                _python.Execute(@"import foo
            foo.test(app)
            foo.test_import(app)", _scope);
            } catch(Exception ex) {
                _repl.OutputBuffer.WriteLine("[FAIL]");
                _repl.OutputBuffer.Write(_python.GetService<Hosting.ExceptionOperations>().FormatException(ex));
            }
        }