Пример #1
0
        public void Run()
        {
            string commandLine = this.userInterface.ReadLine();
            while (commandLine != null && commandLine != "end")
            {
                commandLine = commandLine.Trim();
                if (!string.IsNullOrEmpty(commandLine))
                {
                    try
                    {
                        var command = new Command(commandLine);
                        var commandResult = this.commandHandler.Execute(command);
                        this.userInterface.WriteLine("{0}", commandResult);
                    }
                    catch (ArgumentException ex)
                    {
                        this.userInterface.WriteLine("{0}", ex.Message);
                    }
                    catch (InvalidOperationException ex)
                    {
                        this.userInterface.WriteLine("{0}", ex.Message);
                    }
                }

                commandLine = this.userInterface.ReadLine();
            }
        }
Пример #2
0
        public void Run()
        {
            while (true)
            {
                Console.ForegroundColor = ConsoleColor.White;

                string commandLine = Console.ReadLine();

                if (commandLine == null)
                {
                    break;
                }

                commandLine = commandLine.Trim();

                if (string.IsNullOrEmpty(commandLine))
                {
                    continue;
                }

                try
                {
                    var comando = new Command(commandLine);
                    var commandResult = this.executer.Execute(comando);

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(commandResult);
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                }
            }
        }