Exemplo n.º 1
0
        /// <summary>
        /// Restores the subject to the previous state on the undo stack, and stores the state before undoing to redo stack.
        /// Method <see cref="CanUndo()"/> can be called before calling this method.
        /// </summary>
        /// <seealso cref="Redo()"/>
        public void Undo()
        {
            if (tempMemento != null)
            {
                throw new InvalidOperationException("The complex memento wasn't commited.");
            }

            inUndoRedo = true;
            IMemento <T> top = undoStack.Pop();

            redoStack.Push(top.Restore(ref subject));
            inUndoRedo = false;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Internal <b>DO</b> action with no error checking
 /// </summary>
 /// <param name="m"></param>
 private void _Do(IMemento <T> m)
 {
     redoStack.Clear();
     undoStack.Push(m);
 }