Пример #1
0
        private static void RunProgram(string input)
        {
            try
            {
                if (input.ToLower() == "help")
                {
                    PrintInstructions();
                    return;
                }

                WeatherType weatherType = GetWeatherTypeFromInputString(input);

                Person person = new Person();

                List <IGettingReadyCommand>     commands = ParseCommands(input, person, weatherType);
                IEnumerable <IGettingReadyRule> rules    = rulesRepository.GetRules();

                // Compose the rules evaluator to run through all rules for our commands
                RulesEvaluator evaluator = new RulesEvaluator(rules);

                // Compose the command processor by giving it our commands and the rules evaluator to use
                // for processing the rules on each command
                CommandProcessor commandProcessor = new CommandProcessor(commands, evaluator);

                string output = commandProcessor.Process();
                Console.WriteLine($"\n{output}\n");
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }