/// <summary> /// Builds a command that will be able to undo the undo, then perform the undo. /// </summary> public override HistoryMemento PerformUndo() { HistoryMemento command = new MementoTest(state); state.SetState(value); return(command); }
private void PerformOperation() { // Remember current state. MementoTest mementoTest = new MementoTest(state); // Perform operation that changes state. int nextState = state.GetState() + random.Next(-10, 11); state.SetState(nextState); // Push old state to stack. stack.PushNewCommand(mementoTest); }