public static void RunMemento() { BehaviouralPatterns.Memento.Originator originator = new BehaviouralPatterns.Memento.Originator("Super-duper-super-puper-super."); BehaviouralPatterns.Memento.Caretaker caretaker = new BehaviouralPatterns.Memento.Caretaker(originator); caretaker.backup(); originator.doSomething(); caretaker.backup(); originator.doSomething(); caretaker.backup(); originator.doSomething(); Console.WriteLine(); caretaker.showHistory(); Console.Write("\nClient: Now, let's rollback!\n\n"); caretaker.undo(); Console.Write("\n\nClient: Once more!\n\n"); caretaker.undo(); Console.WriteLine(); Console.ReadKey(); }
public Caretaker(Originator originator) { this.originator = originator; }