コード例 #1
0
ファイル: Program.cs プロジェクト: ajlopez/AjSharp
        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();
        }
コード例 #2
0
ファイル: ExecuteSubroutine.cs プロジェクト: ajlopez/AjSharp
        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;
        }
コード例 #3
0
ファイル: RemotingHostServer.cs プロジェクト: ajlopez/AjSharp
        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);
            }
        }
コード例 #4
0
ファイル: SerializationTests.cs プロジェクト: ajlopez/AjSharp
 private ICommand ProcessCommand(string commandtext)
 {
     Parser parser = new Parser(commandtext);
     ICommand command = parser.ParseCommand();
     return (ICommand)this.SerializeDeserialize(command);
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: ajlopez/AjSharp
        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();
            }
        }
コード例 #6
0
ファイル: ParserTests.cs プロジェクト: ajlopez/AjSharp
        private static ICommand ParseCommand(string text)
        {
            Parser parser = new Parser(text);

            ICommand command = parser.ParseCommand();

            Assert.IsNull(parser.ParseCommand());

            return command;
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: ajlopez/AjSharp
        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();
        }
コード例 #8
0
ファイル: HostEvaluationTest.cs プロジェクト: ajlopez/AjSharp
        private void ExecuteCommand(string text)
        {
            Parser parser = new Parser(text);

            ICommand command = parser.ParseCommand();

            this.host.Execute(command);
        }
コード例 #9
0
ファイル: EvaluationTests.cs プロジェクト: ajlopez/AjSharp
        private void ExecuteCommand(string text)
        {
            Parser parser = new Parser(text);

            ICommand command = parser.ParseCommand();

            command.Execute(this.machine.Environment);
        }