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());
        }
        public static void Main()
        {
            // first bottleneck - it is better to use the multidictionary (EventManagerFast) since removing a lot of elements in list is slow operation
            EventsManagerFast eventsManager    = new EventsManagerFast();
            CommandProcessor  commandProcessor = new CommandProcessor(eventsManager);

            while (true)
            {
                string command = Console.ReadLine();

                if (command == "End" || command == null)
                {
                    break;
                }

                try
                {
                    Console.WriteLine(commandProcessor.ProcessCommand(Command.Parse(command)));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        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)));
            }
        }
        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)));
            }
        }