예제 #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();
        }
예제 #2
0
파일: Memento.cs 프로젝트: rahuldixit/Go4
 public Caretaker(Originator originator)
 {
     this.originator = originator;
 }