Exemple #1
0
        public void ExecuteCommand(Command commandObj)
        {
            var obj = new CommandWithMemento
            {
                Command = commandObj,
                Memento = commandObj.Execute()
            };

            UndoStack.Push(obj);
            RedoStack.Clear();
        }
Exemple #2
0
 public string Undo()
 {
     if (UndoPossible())
     {
         CommandWithMemento obj = UndoStack.Pop();
         var memento            = obj.Memento;
         var command            = obj.Command;
         command.Subject.RestoreMemento(memento);
         RedoStack.Push(obj);
         return("Executed Undo: " + command.Action.Method.Name);
     }
     else
     {
         return("Nothing to Undo");
     }
 }
Exemple #3
0
        public string Redo()
        {
            if (RedoPossible())
            {
                var obj  = RedoStack.Pop();
                var obj2 = new CommandWithMemento()
                {
                    Command = obj.Command,
                    Memento = obj.Command.Execute()
                };

                UndoStack.Push(obj2);
                return("Executed Redo: " + obj2.Command.Action.Method.Name);
            }
            else
            {
                return("Nothing to Redo");
            }
        }