예제 #1
0
        static void Main(string[] args)
        {
            SalesProspect s = new SalesProspect();

            s.Name   = "Noel van Halen";
            s.Phone  = "(412) 256-0990";
            s.Budget = 25000.0;

            // Store internal state

            ProspectMemory m = new ProspectMemory();

            m.Memento = s.SaveMemento();

            // Continue changing originator

            s.Name   = "Leo Welch";
            s.Phone  = "(310) 209-7111";
            s.Budget = 1000000.0;

            // Restore saved state

            s.RestoreMemento(m.Memento);

            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var salesProspect = new SalesProspect();

            salesProspect.Name   = "Leo van Halen";
            salesProspect.Phone  = "(050) 000-0000";
            salesProspect.Budget = 20000.0;

            var prospectMemory = new ProspectMemory();

            prospectMemory.Memento = salesProspect.SaveMemento();

            salesProspect.Name   = "Fred Welch";
            salesProspect.Phone  = "(099) 000-0000";
            salesProspect.Budget = 40000.0;

            salesProspect.RestoreMemento(prospectMemory.Memento);

            Console.ReadLine();
        }
예제 #3
0
        public static void Execute_Example()
        {
            SalesProspect s = new SalesProspect();

            s.Name   = "Noel van Halen";
            s.Phone  = "(412) 256-0990";
            s.Budget = 25000.0;

            // Store internal state
            ProspectMemory m = new ProspectMemory();

            m.Memento = s.SaveMemento();

            // Continue changing originator
            s.Name   = "Leo Welch";
            s.Phone  = "(310) 209-7111";
            s.Budget = 1000000.0;

            // Restore saved state
            s.RestoreMemento(m.Memento);

            // Wait for user
            Console.ReadKey();
        }