Ejemplo n.º 1
0
 public void Do(IUndoableCommand command, string commandName = "")
 {
     if (command != null)
     {
         if (RecordingSessionInProgress)
         {
             command.Do();
             transactionRecords.Peek().CommandsGroup.Commands.Add(command);
         }
         else
         {
             command.Do();
             redoCommands.Clear();
             undoCommands.Push(new CommandRecord {
                 Command = command, CommandName = commandName
             });
             OnPropertyChanged(nameof(UndoableCommands));
             OnPropertyChanged(nameof(RedoableCommands));
         }
     }
 }
        /// <summary>
        /// Internal method for executing a command with a specific context.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="context">The context of the execution.</param>
        protected virtual void Do(
            IUndoableCommand <TContext> command,
            TContext context)
        {
            // Establish our contracts.
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // Execute the command and get its state.
            command.Do(context);
        }
Ejemplo n.º 3
0
 public void ExecuteCommand(IUndoableCommand command)
 {
     commandsDone.Push(command);
     command.Do();
 }