示例#1
0
        public void ParseTest()
        {
            CommandsProcessor cp = new CommandsProcessor();

            Assert.IsInstanceOfType(cp.Parse("events"), typeof(PullEvents));
            Assert.IsInstanceOfType(cp.Parse("mypos 0 0"), typeof(MyDestination));

            MyDestination myposValid = cp.Parse("mypos 10 20") as MyDestination;

            Assert.IsTrue(myposValid.X == 10 && myposValid.Y == 20);

            Assert.ThrowsException <Exception>(() => cp.Parse("mypos 10 20 30"));
            Assert.ThrowsException <Exception>(() => cp.Parse("mypos a b"));
        }
示例#2
0
        static void Main(string[] args)
        {
            CommandsProcessor proc = new CommandsProcessor();

            ICommand version = proc.Parse("version");

            Console.WriteLine(version.exec());


            proc.Parse("connect judgeGC LoadLibrary").exec();


            Console.WriteLine("Подключаемся...");
            ICommand isConnected = proc.Parse("iscon");

            while (isConnected.exec() != true.ToString().ToLower())
            {
                Thread.Sleep(250);
            }
            Console.WriteLine("Подключение установлено");

            while (true)
            {
                try
                {
                    ICommand events     = proc.Parse("events");
                    string   eventsList = events.exec();
                    if (eventsList.Length > 0)
                    {
                        Console.WriteLine(eventsList);
                    }

                    Thread.Sleep(200);

                    ICommand mypos = proc.Parse("mypos 5 5");
                    mypos.exec();

                    Thread.Sleep(300);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#3
0
        public static void RVExtension(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function)
        {
            try
            {
                CommandsProcessor proc = new CommandsProcessor();
                ICommand          cmd  = proc.Parse(function);

                output.Append(cmd.exec());
            }catch (Exception ex)
            {
                Logger.StackTrace(ex);
            }
        }