BalloonsPop.ConsoleUI.ConsoleEngine.Run C# (CSharp) Method

Run() public method

public Run ( ) : void
return void
        public void Run()
        {
            this.Context.Printer.PrintField(this.Context.Game.Field);
            var command = string.Empty;

            while (true)
            {
                this.Context.Message = MovePrompt;
                this.CommandFactory.CreateCommand(PrintMessageCommandKey).Execute(this.Context);
                command = this.GetTrimmedUppercaseInput();

                var parsedCommand = this.GetCommand(command);
                parsedCommand.Execute(this.Context);
            }
        }

Usage Example

Beispiel #1
0
        public static void Main()
        {
            Logger.Info("Start initialization.");
            var kernel = new StandardKernel();

            // TODO: create logger module
            kernel.Bind<ILogger>().ToMethod(x => LogHelper.GetLogger());
            DependancyBinder.Instance
                .RegisterModules(
                    new ModelsModule(kernel),
                    new LogicModule(kernel),
                    new ValidationModule(kernel),
                    new CommandModule(kernel),
                    new HighscoreModule(kernel),
                    new SaverModule(kernel),
                    new ConsoleModule(kernel))
                .LoadAll();

            var ctx = new Context(kernel);
            var bundle = new ConsoleBundle(kernel);

            // TODO: extract in a module
            bundle.CommandFactory.RegisterCommand("exit", () => new ExitCommand());

            var engine = new ConsoleEngine(ctx, bundle);

            Logger.Info("Starting the game.");
            engine.Run();
        }