public static void Main(string[] args) { foreach (string arg in args) if (IsLocalAddress(arg)) ProcessLocalAddress(arg); else ProcessRemoteAddress(arg); foreach (IHost host in remotehosts) { Parser parser = new Parser("PrintLine(\"Hello, world\");"); ICommand cmd = parser.ParseCommand(); host.Execute(cmd); parser = new Parser("new DynamicObject()"); IObject result = (IObject)host.Evaluate(parser.ParseExpression()); host.Invoke(result, "SetValue", new object[] { "Print", new Function(null, cmd) }); object func = host.Invoke(result, "GetValue", new object[] { "Print" }); host.Invoke(result, "Print", null); // Function function = new Function(null, cmd); // result.SetValue("Print", function); // result.Invoke("Print", null); } Console.ReadLine(); }
public object Invoke(IBindingEnvironment environment, object[] arguments) { if (arguments == null || arguments.Length != 1) throw new InvalidOperationException("Invalid number of parameters"); string text = (string)arguments[0]; Parser parser = new Parser(text); ICommand command; while ((command = parser.ParseCommand()) != null) command.Execute(environment); return null; }
public override void Execute(string commandtext) { Machine current = Machine.Current; try { Machine.SetCurrent(this.Machine); Parser parser = new Parser(commandtext); ICommand command; while ((command = parser.ParseCommand()) != null) command.Execute(this.Machine.Environment); } finally { Machine.SetCurrent(current); } }
private ICommand ProcessCommand(string commandtext) { Parser parser = new Parser(commandtext); ICommand command = parser.ParseCommand(); return (ICommand)this.SerializeDeserialize(command); }
public static void Main(string[] args) { // According http://msdn.microsoft.com/en-us/magazine/cc300474.aspx LifetimeServices.LeaseTime = TimeSpan.FromMinutes(10); LifetimeServices.RenewOnCallTime = TimeSpan.FromMinutes(15); LifetimeServices.SponsorshipTimeout = TimeSpan.FromMinutes(1); AjSharpMachine machine = new AjSharpMachine(); Parser parser; ICommand command; foreach (string filename in args) { try { parser = new Parser(System.IO.File.ReadAllText(filename)); while ((command = parser.ParseCommand()) != null) command.Execute(machine.Environment); } catch (ExitException) { return; } catch (Exception ex) { if (ex.InnerException != null) { Console.Error.WriteLine(ex.InnerException.Message); Console.Error.WriteLine(ex.InnerException.StackTrace); } Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); } } try { parser = new Parser(machine.In); command = parser.ParseCommand(); while (command != null) { command.Execute(machine.Environment); command = parser.ParseCommand(); } } catch (ExitException) { return; } catch (Exception ex) { if (ex.InnerException != null) { Console.Error.WriteLine(ex.InnerException.Message); Console.Error.WriteLine(ex.InnerException.StackTrace); } Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); Console.ReadLine(); } }
private static ICommand ParseCommand(string text) { Parser parser = new Parser(text); ICommand command = parser.ParseCommand(); Assert.IsNull(parser.ParseCommand()); return command; }
public static void Main(string[] args) { foreach (string address in args) { if (address[0] == '-') continue; servers.Add(new WcfHostServer(address)); } foreach (WcfHostServer server in servers) server.Open(); foreach (string address in args) { if (address[0] != '-') continue; channels.Add(new WcfHostClient(address.Substring(1))); } try { Parser parser = new Parser("new DynamicObject()"); IExpression expression = parser.ParseExpression(); if (channels.Count > 0) { object result = channels[0].Evaluate(expression); } parser = new Parser(System.Console.In); ICommand command = parser.ParseCommand(); while (command != null) { channels[0].Execute(command); command = parser.ParseCommand(); } } catch (ExitException) { } catch (Exception ex) { if (ex.InnerException != null) { Console.Error.WriteLine(ex.InnerException.Message); Console.Error.WriteLine(ex.InnerException.StackTrace); } Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(ex.StackTrace); Console.ReadLine(); } foreach (WcfHostServer server in servers) server.Close(); }
private void ExecuteCommand(string text) { Parser parser = new Parser(text); ICommand command = parser.ParseCommand(); this.host.Execute(command); }
private void ExecuteCommand(string text) { Parser parser = new Parser(text); ICommand command = parser.ParseCommand(); command.Execute(this.machine.Environment); }