Пример #1
0
        static void Main()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IParser <string, long>, NumberParser>()
                                  .AddSingleton <IRulesEngine <long, string>, AmericanNumberFormatRulesEngine>()
                                  .AddSingleton <IRulesProcessor <long, string>, MultiThreadedRulesProcessor <long, string> >()
                                  .AddSingleton <IInputterDialogue <string>, ConsoleFileNameDialogue>()
                                  .AddSingleton <IInputter <string>, FileInputter>()
                                  .AddSingleton <IOutputter <string>, StdOutStringOutputter>()
                                  .BuildServiceProvider();

            bool run = true;

            while (run)
            {
                try
                {
                    IParser <string, long> parser           = serviceProvider.GetService <IParser <string, long> >();
                    IList <long>           numbersToConvert = parser.ParseInput(serviceProvider.GetService <IInputter <string> >().Get());

                    IRulesProcessor <long, string> rulesProcessor = serviceProvider.GetService <IRulesProcessor <long, string> >();
                    IList <string> wordsConverted = rulesProcessor.Process(numbersToConvert);

                    IOutputter <string> outputter = serviceProvider.GetService <IOutputter <string> >();
                    outputter.Output(wordsConverted);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                Console.WriteLine("Run Again y/n?");
                run = Console.ReadLine().ToLower() == "y" ? true : false;
            }
        }
Пример #2
0
        private void cbSource_SelectedIndexChanged(object sender, EventArgs ea)
        {
            PopulateSettings();

            if (_processor != null)
            {
                _processor.ErrorHappened -= processor_ErrorHappened;
            }

            //EnterpriseConnection connection = new EnterpriseConnection(_settings.username, _settings.password, _settings.account, _settings.source);
            //connection.ConnectionId = "4";

            Twitter1PercentConnection connection = new Twitter1PercentConnection(_settings.username, _settings.password, _settings.account);

            connection.IsLive = _settings.live;

            IRulesProcessor processor = GnipRulesProcessor.CreateRulesProcessor(connection);

            processor.ErrorHappened += processor_ErrorHappened;

            _processor = processor;
        }
Пример #3
0
 public GildedRoseRefactored(IRulesProcessor rulesProcessor)
 {
     _rulesProcessor = rulesProcessor;
 }