Beispiel #1
0
        public void Parse()
        {
            CommandAnalyser com = new CommandAnalyser();

            com.Write = Write;
            //Assert.IsFalse(com.TESTING);
            com.Execute("Help");
            //Assert.IsTrue(com.TESTING);
        }
Beispiel #2
0
        private static void AnalyzeCommand(string userInput)
        {
            CommandAnalyser analyser = new CommandAnalyser(commander, userInput);

            object[] arguments = null;
            if (analyser.GetRequiredArguments(out var parameters))
            {
                arguments = PrintArguments(parameters);
            }

            var x = analyser.Execute(arguments);
            //if (x is IEnumerable<DynamicObject>)
            //{
            //    var jsonRepos = new AdminRepository(x as IEnumerable<DynamicObject>);
            //    return;
            //}
            //var repository = new AdminRepository();
            //if (x != null && repository.Get(a => (a as DynamicObject).Name == (x as DynamicObject).Name) == null)
            //    repository.Add(x as ISimObject);
            //else
            //    repository.Update(x as ISimObject);
        }
        private void txtConsole_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                e.Handled = true;
                string comm = ReadLine();
                if (!String.IsNullOrWhiteSpace(comm))
                {
                    AddToCommandBuffer(comm);
                    CircularBufferReadIndex = CircularBufferWriteIndex;
                    CircularBufferReadIndex--;
                    Console.Execute(comm);
                }
                else
                {
                    ConsoleWrite("");
                }
                break;

            case Keys.Oem4:
                e.Handled          = true;
                e.SuppressKeyPress = true;
                string temp = ReadLine();
                Console.Execute(temp + "?");
                //ConsoleWrite("");
                txtConsole.AppendText(temp);
                break;

            case Keys.Up:
                e.Handled = true;
                //txtConsole.Lines[txtConsole.Lines.LongLength- 1] = consoletext;
                txtConsole.SelectionStart  = txtConsole.GetFirstCharIndexFromLine(txtConsole.Lines.Length - 1);
                txtConsole.SelectionLength = txtConsole.Lines[txtConsole.Lines.Length - 1].Length + 1;
                txtConsole.SelectedText    = String.Empty;
                for (int i = 0; i < CommadBuffer.Length; i++)
                {
                    if (CommadBuffer[(CircularBufferReadIndex + CommadBuffer.Length - 1) % CommadBuffer.Length] != null)
                    {
                        ConsoleBufferWrite(consoletext + CommadBuffer[(CircularBufferReadIndex + CommadBuffer.Length - 1) % CommadBuffer.Length]);
                        CircularBufferReadIndex = Convert.ToByte((CircularBufferReadIndex + CommadBuffer.Length - 1) % CommadBuffer.Length);
                        break;
                    }
                    CircularBufferReadIndex = Convert.ToByte((CircularBufferReadIndex + CommadBuffer.Length - 1) % CommadBuffer.Length);
                }
                break;

            case Keys.Down:
                txtConsole.SelectionStart  = txtConsole.GetFirstCharIndexFromLine(txtConsole.Lines.Length - 1);
                txtConsole.SelectionLength = txtConsole.Lines[txtConsole.Lines.Length - 1].Length + 1;
                txtConsole.SelectedText    = String.Empty;
                for (int i = 0; i < CommadBuffer.Length; i++)
                {
                    if (CommadBuffer[(CircularBufferReadIndex + CommadBuffer.Length + 1) % CommadBuffer.Length] != null)
                    {
                        ConsoleBufferWrite(consoletext + CommadBuffer[(CircularBufferReadIndex + CommadBuffer.Length + 1) % CommadBuffer.Length]);
                        CircularBufferReadIndex = Convert.ToByte((CircularBufferReadIndex + CommadBuffer.Length + 1) % CommadBuffer.Length);
                        break;
                    }
                    CircularBufferReadIndex = Convert.ToByte((CircularBufferReadIndex + CommadBuffer.Length + 1) % CommadBuffer.Length);
                }
                break;
            }
        }