예제 #1
0
        static void Example()
        {
            var originator = new Example.Originator("Originator's initial state");
            var caretaker  = new Example.Caretaker(originator);

            caretaker.Backup();
            originator.DoSomething();

            caretaker.Backup();
            originator.DoSomething();

            caretaker.Backup();
            originator.DoSomething();

            Console.WriteLine();
            caretaker.ShowHistory();

            Console.WriteLine("\nClient: Now, let's rollback!\n");
            caretaker.Undo();

            Console.WriteLine("\n\nClient: Once more!\n");
            caretaker.Undo();
        }
 public Caretaker(Originator originator)
 {
     _originator = originator;
 }