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

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

            ProspectMemory m = new ProspectMemory()
            {
                Memento = s.SaveMemento()
            };

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

            s.RestoreMemento(m.Memento);

            Console.ReadKey();
        }
예제 #2
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main(string[] args)
        {
            SalesProspect salesProspect = new SalesProspect();

            salesProspect.Name   = "SANTA CLAUS";
            salesProspect.Phone  = "0 111 222 333";
            salesProspect.Budget = 25000.0;

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

            prospectMemory.Memento = salesProspect.SaveMemento();

            // Continue changing originator
            salesProspect.Name   = "SILVESTER STALONE";
            salesProspect.Phone  = "0 333 444 555";
            salesProspect.Budget = 1000000.0;

            // Restore saved state
            salesProspect.RestoreMemento(prospectMemory.Memento);

            Console.ReadLine();
        }