Beispiel #1
0
        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();
        }
Beispiel #2
0
 public Caretaker(Originator originator)
 {
     this.originator = originator;
 }