public void Executig_it_should_redirect_the_given_command_to_initialized_action()
        {
            var theCommand = new TheCommand();
            Action<ICommand> action = (c) => c.Should().BeSameAs(theCommand);

            var target = new CommandExecutorWrapper<ICommand>(action);
            target.Execute(theCommand);
        }
        public void Executig_it_should_redirect_the_given_command_to_initialized_action()
        {
            var theCommand           = new TheCommand();
            Action <ICommand> action = (c) => c.Should().BeSameAs(theCommand);

            var target = new CommandExecutorWrapper <ICommand>(action);

            target.Execute(theCommand);
        }
        public void Executig_it_should_redirect_call_to_initialized_action()
        {
            bool redirected = false;
            Action<ICommand> action = (c) => redirected = true;
            var cmd = new TheCommand();

            var target = new CommandExecutorWrapper<ICommand>(action);
            target.Execute(cmd);

            redirected.Should().BeTrue();
        }
示例#4
0
        public void Executig_it_should_redirect_call_to_initialized_action()
        {
            bool redirected          = false;
            Action <ICommand> action = (c) => redirected = true;
            var cmd = new TheCommand();

            var target = new CommandExecutorWrapper <ICommand>(action);

            target.Execute(cmd);

            redirected.Should().BeTrue();
        }
示例#5
0
 public void Undo(int levels)
 {
     Console.WriteLine("\n---- Undo {0} levels ", levels);
     // Perform undo operations
     for (int i = 0; i < levels; i++)
     {
         if (_current > 0)
         {
             TheCommand command = _commands[--_current] as TheCommand;
             command.UnExecute();
         }
     }
 }
示例#6
0
 public void Redo(int levels)
 {
     Console.WriteLine("\n---- Redo {0} levels ", levels);
     // Perform redo operations
     for (int i = 0; i < levels; i++)
     {
         if (_current < _commands.Count - 1)
         {
             TheCommand command = _commands[_current++];
             command.Execute();
         }
     }
 }
示例#7
0
        public static void ResolveInternalCommand(QuarterServer server, string raw)
        {
            Command TheCommand = null;

            if (raw.StartsWith("."))
            {
                raw = raw.Substring(1);

                Command[] AllCommands =
                {
                    new ShowHelpCommand(server,     raw),
                    new ShowFlagCommand(server,     raw),
                    new ChangeFlagCommand(server,   raw),
                    new ListClientCommand(server,   raw),
                    new StopServerCommand(server,   raw),
                    new AllowClientCommand(server,  raw),
                    new KickClientCommand(server,   raw),
                    new SendToClientCommand(server, raw)
                };

                foreach (Command c in AllCommands)
                {
                    if (c.IsMatch())
                    {
                        TheCommand = c;
                        break;
                    }
                }
            }
            else
            {
                TheCommand = new SendToClientCommand(server, "send @p " + raw);
            }

            if (TheCommand == null)
            {
                Red("Unknown command\n");
                PrintInternalCommandHelp();
                return;
            }

            try
            {
                TheCommand.Handle();
            }
            catch
            {
                Red("Command exception\n");
                PrintInternalCommandHelp();
            }
        }
示例#8
0
 public Task Handle(TheCommand message, IMessageHandlerContext context)
 {
     Console.WriteLine($"Command received: #{message.IntProperty}");
     return(Task.CompletedTask);
 }