internal static void Main()
        {
            var eventManager = new EventsManagerFast();
            var commandParser = new CommandParser();
            var printer = new StringBuilderPrinter();
            var commandFactory = new CommandFactory(eventManager, printer);
            var consolePrinter = new ConsolePrinterVisitor();

            while (true)
            {
                string userLine = Console.ReadLine();
                if (userLine == "End" || userLine == null)
                {
                    break;
                }

                try
                {
                    var commandInfo = commandParser.Parse(userLine);
                    var command = commandFactory.Create(commandInfo);
                    command.Execute(commandInfo.Arguments);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            printer.Accept(consolePrinter);
        }
示例#2
0
        internal static void Main()
        {
            IEventsManager eventsManager = new EventsManager();
            CommandParser parser = new CommandParser(eventsManager);

            while (true)
            {
                string command = Console.ReadLine();
                if (command == "End" || command == null)
                {
                    break;
                }

                try
                {
                    Console.WriteLine(parser.ProcessCommand(Command.Parse(command)));
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("You've entered and invalid command.");
                }
            }
        }
 public void CreateParserInstance()
 {
     this.parser = new CommandParser();
 }