Пример #1
0
        /// <summary>
        /// Prepares console, print menu, take command from user, check if is right and execute it.
        /// </summary>
        /// <param name="ui">IUI that prints massages.</param>
        /// <param name="commandFactory">Command to execute.</param>
        public static void Start(IUI ui, CommandFactory commandFactory)
        {
            ui.Initialize();

            while (true)
            {
                ui.ReInitizlize();

                string commandToExecute = ui.ReadLine();  

                if (Globals.MenuCommandTypesValue.ContainsKey(commandToExecute))
                {
                    var command = commandFactory.GetMenuCommand(commandToExecute, ui, Globals.MenuCommandTypesValue);
                    command.Execute();
                }
                else
                {
                    ui.Print(Messages.WrongMessage, "Message");
                }
            }
        }