Пример #1
0
        public bool RunCommand(string userInput)
        {
            bool legalInput = true;

            string[] inputParts = userInput.Split();

            CliShellCommand wanted_command = this._commands.Where(c => c.Keyword == inputParts[0]).FirstOrDefault();

            if (wanted_command != null)
            {
                // Run command.
                string commandData = userInput.Substring(userInput.IndexOf(" ") + 1);
                wanted_command.Action(commandData);
            }
            else
            {
                Console.WriteLine("Illegal Input.");
                legalInput = false;
            }

            return(legalInput);
        }
Пример #2
0
 public void AddCommand(CliShellCommand cliShellCommand)
 {
     this._commands.Add(cliShellCommand);
 }