public void Start()
        {
            while (true)
            {
                // read from console
                var reader = new ConsoleReaderProvider();
                var writer = new ConsoleWriterProvider();

                var commandFromInput = reader.ReadLine();

                if (commandFromInput.ToLower() == TerminationCommand.ToLower())
                {
                    writer.WriteLine("Program terminated.");
                    break;
                }

                try
                {
                    var executionResult = this.processor.Process(commandFromInput);
                }
                catch (UserValidationException ex)
                {
                    writer.WriteLine(ex.Message);
                }
                catch (Exception ex)
                {
                    writer.WriteLine(ex.Message);
                    this.logger.Error(ex.Message);
                }
            }
        }
Exemple #2
0
 public EngineModule(ConsoleReaderProvider consoleReaderProvider,
                     ConsoleWriterProvider consoleWriterProvider, CommandParserProvider commandParserProvider)
 {
     this.consoleReaderProvider = consoleReaderProvider;
     this.consoleWriterProvider = consoleWriterProvider;
     this.commandParserProvider = commandParserProvider;
 }
Exemple #3
0
        private static Engine GetEngineInstance()
        {
            IWriterProvider  writer          = new ConsoleWriterProvider();
            IReaderProvider  reader          = new ConsoleReaderProvider();
            ICommandProvider commandProvider = new CommandProvider();
            Engine           engine          = new Engine(reader, writer, commandProvider);

            return(engine);
        }
Exemple #4
0
        public static void Main()
        {
            var readerProvider = new ConsoleReaderProvider();
            var writerProvider = new ConsoleWriterProvider();
            var parserProvider = new CommandParserProvider();
            var engine         = new Engine(readerProvider, writerProvider, parserProvider);

            engine.Run();
        }
Exemple #5
0
        public static void Main()
        {
            IReader reader = new ConsoleReaderProvider();
            IWriter writer = new ConsoleWriterProvider();
            IParser parser = new CommandParserProvider();

            Engine engine = new Engine(reader, writer, parser);

            engine.Start();
        }
Exemple #6
0
        public static void Main()
        {
            var reader         = new ConsoleReaderProvider();
            var writer         = new ConsoleWriterProvider();
            var commandFactory = new CommandFactory(reader, writer);

            var menu = new Menu(reader, writer, commandFactory);

            menu.Start();
        }
        public static void Main()
        {
            var reader       = new ConsoleReaderProvider();
            var writer       = new ConsoleWriterProvider();
            var levelFactory = new LevelFactory();


            var engine = new GameEngine(levelFactory, reader, writer);

            engine.StartGame();
        }
Exemple #8
0
        public static void Main()
        {
            var modelsFactory = new ModelsFactory();
            var database      = new Database();

            var commandsFactory = new CommandsFactory(database, modelsFactory);

            var commandProcessor = new CommandProcessor(commandsFactory);

            var fileLogger = new FileLogger();

            var engineReader = new ConsoleReaderProvider();

            var engineWriter = new ConsoleWriterProvider();

            var engine = new Engine(fileLogger, commandProcessor, engineReader, engineWriter);

            var provider = new EngineProvider(engine);

            provider.StartEngine();
        }