/// <summary>
        /// The test first.
        /// </summary>
        private static void TestFirst()
        {
            SalesProspect salesProspect = new SalesProspect
            {
                Name   = "Noel van Halen",
                Phone  = "(412) 256-0990",
                Budget = 25000.0
            };

            // Store internal state
            ProspectMemory prospectMemory =
                new ProspectMemory {
                Memento = salesProspect.SaveMemento()
            };

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

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

            // Wait for user
            Console.ReadKey();
        }
Exemple #2
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);

            // Wait for user

            Console.ReadKey();
        }
Exemple #3
0
        internal static void Main()
        {
            var sale = new SalesProspect { Name = "Noel van Halen", Phone = "(412) 256-0990", Budget = 25000.0 };

            // Store internal state
            var memory = new ProspectMemory();
            memory.Memento = sale.SaveMemento();

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

            // Restore saved state
            sale.RestoreMemento(memory.Memento);
        }
 /// <summary>
 /// Entry point into console application.
 /// </summary>
 static void Main()
 {
     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();
 }
Exemple #5
0
        internal static void Main()
        {
            var sale = new SalesProspect {
                Name = "Noel van Halen", Phone = "(412) 256-0990", Budget = 25000.0
            };

            // Store internal state
            var memory = new ProspectMemory();

            memory.Memento = sale.SaveMemento();

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

            // Restore saved state
            sale.RestoreMemento(memory.Memento);
        }
Exemple #6
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            SalesProspect s = new SalesProspect();

            s.Name   = "Maham Nazir";
            s.Phone  = "(+92) 321-2112110";
            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);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            SalesProspect s = new SalesProspect();

            s.Name   = "Teste";
            s.Phone  = "(00) 00000-0000";
            s.Budget = 25000.0;


            ProspectMemory m = new ProspectMemory();

            m.Memento = s.SaveMemento();

            s.Name   = "Teste 2";
            s.Phone  = "(00) 0000-0000";
            s.Budget = 1000000.0;

            s.RestoreMemento(m.Memento);


            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            SalesProspect salesProspect = new SalesProspect();

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

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

            prospectMemory.Memento = salesProspect.SaveMemento();

            salesProspect.Name   = "Leo Welch";
            salesProspect.Phone  = "(310) 209-7111";
            salesProspect.Budget = 1000000;

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

            Console.ReadKey();
        }
        public static void Run()
        {
            Console.WriteLine("This real-world code demonstrates the Memento pattern which temporarily saves and then restores the SalesProspect's internal state.\n");
            SalesProspect s = new SalesProspect();

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

            ProspectMemory m = new ProspectMemory();

            m.Memento = s.SaveMemento();

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

            s.RestoreMemento(m.Memento);
            Console.WriteLine("----");

            /*
             * Name:   Noel van Halen
             * Phone:  (412) 256-0990
             * Budget: 25000
             *
             * Saving state --
             *
             * Name:   Leo Welch
             * Phone:  (310) 209-7111
             * Budget: 1000000
             *
             * Restoring state --
             *
             * Name:   Noel van Halen
             * Phone:  (412) 256-0990
             * Budget: 25000
             */
        }