Пример #1
0
        /// <summary>
        /// Entry point of the application
        /// </summary>
        internal static void Main()
        {
            var eventsManager = new EventsManagerFast();
            var processor = new CommandProcessor(eventsManager);
            var output = new StringBuilder();

            while (true)
            {
                string commandText = Console.ReadLine();
                if (commandText == EndCommandString || commandText == null)
                {
                    // The sequence of commands is finished
                    break;
                }

                try
                {
                    var command = Command.Parse(commandText);
                    var result = processor.ProcessCommand(command);
                    output.AppendLine(result);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    break;
                }
            }

            Console.WriteLine(output);
        }
        internal static void Main()
        {
            // FastEventsManager is faster than EventManager - bottleneck
            IEventsManager eventsManager = new FastEventsManager();
            CommandProcessor commandProcessor = new CommandProcessor(eventsManager);

            // With StringBuider it's easier to view the output and it's around 10s faster than
            // printing every time the command's output - bottleneck
            StringBuilder output = new StringBuilder();
            while (true)
            {
                string inputLine = Console.ReadLine();
                if (inputLine == "End" || inputLine == null)
                {
                    break;
                }

                try
                {
                    Command commandToProcess = Command.Parse(inputLine);
                    output.AppendLine(commandProcessor.ProcessCommand(commandToProcess));
                }
                catch (ArgumentException argException)
                {
                    Console.WriteLine(argException.Message);
                }
            }

            Console.Write(output.ToString());
        }
        internal static void Main()
        {
            var eventsManager = new EventsManager();
            var processor = new CommandProcessor(eventsManager);

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

               // Read sequence of commands, untill is finished and display results
               Console.WriteLine(processor.ProcessCommand(Command.Parse(inputCommand)));
            }
        }