public object[] Eval(IRpcContext context, List <string> Args) { GetParams(Args); _controller = BeginProcess(_processName); var ctx = _controller.CreateScriptContextFromString(_code); ctx.Execute(); //code.Run(_controller.Scope); return(new object[0]); }
public void Run() { // var code = new StreamReader(Resources.ResourceManager.GetStream("TextFile1.py")).ReadToEnd(); _controller = new ScriptController(false); _controller.OnMessage += (sender, message) => { //Console.WriteLine(message); // Console.WriteLine(String.Format("[{0:HH:MM:ss:fff}][SCRIPT]:{1}", DateTime.Now, message.Trim())); Console.WriteLine(String.Format("{0}", message.Trim())); }; var code = Resources.ResourceManager.GetString("ScriptHeader1"); dynamic handler = null; IScriptContext ctx; try { if (string.IsNullOrEmpty(script)) { script = code; ctx = _controller.CreateScriptContextFromString(script); ctx.Execute(); } else { ctx = _controller.CreateScriptContextFromFile(script); ctx.ExecuteString(code); ctx.Execute(); } handler = ctx.Scope.CreateHandler(); } catch (Exception e) { Console.WriteLine(e.Message); return; } _mainProcess = new PyProcessContext(ctx, handler, _processFactory, command, CommandArguments, workingDirectory, _commandParameters); _mainProcess.Start(); ctx.FlushBuffer(); // Console.ReadKey(); }
public IScriptContext Compile(string Code) { try { _engine = new ScriptController(true); _context = _engine.CreateScriptContextFromString(Code, _context); foreach (var de in _variables) { _context.SetVariable(de.Key, de.Value); } _engine.OnMessage += new MessageEvent(_engine_OnMessage); return(_context); } catch (Exception e) { LogMessage(e.Message); return(null); } }
public object[] Eval(IRpcContext context, List<string> Args) { GetParams(Args); _controller = BeginProcess(_processName); var ctx = _controller.CreateScriptContextFromString(_code); ctx.Execute(); //code.Run(_controller.Scope); return new object[0]; }
public IScriptContext Compile(string Code) { try { _engine = new ScriptController(true); _context = _engine.CreateScriptContextFromString(Code, _context); foreach (var de in _variables) { _context.SetVariable(de.Key, de.Value); } _engine.OnMessage += new MessageEvent(_engine_OnMessage); return _context; } catch (Exception e) { LogMessage(e.Message); return null; } }
public void Run() { // var code = new StreamReader(Resources.ResourceManager.GetStream("TextFile1.py")).ReadToEnd(); _controller = new ScriptController(false); _controller.OnMessage += (sender, message) => { //Console.WriteLine(message); // Console.WriteLine(String.Format("[{0:HH:MM:ss:fff}][SCRIPT]:{1}", DateTime.Now, message.Trim())); Console.WriteLine(String.Format("{0}", message.Trim())); }; var code = Resources.ResourceManager.GetString("ScriptHeader1"); dynamic handler = null; IScriptContext ctx; try { if (string.IsNullOrEmpty(script)) { script = code; ctx = _controller.CreateScriptContextFromString(script); ctx.Execute(); } else { ctx = _controller.CreateScriptContextFromFile(script); ctx.ExecuteString(code); ctx.Execute(); } handler = ctx.Scope.CreateHandler(); } catch (Exception e) { Console.WriteLine(e.Message); return; } _mainProcess = new PyProcessContext(ctx, handler, _processFactory, command, CommandArguments, workingDirectory, _commandParameters); _mainProcess.Start(); ctx.FlushBuffer(); // Console.ReadKey(); }