static void Main(string[] args)
            {
                var originator = new Originator <Udemy>();
                var careTaker  = new CareTaker <Udemy>();

                originator.State = new Udemy
                {
                    DersNo  = "01",
                    DersAdi = "Gerekli Kurulumlar"
                };

                careTaker.Add(originator.SetState());

                originator.State = new Udemy
                {
                    DersNo  = "29",
                    DersAdi = "Çember Tespiti"
                };

                careTaker.Add(originator.SetState());

                originator.GetState(careTaker[0]);

                Console.WriteLine(originator.State);
            }
Beispiel #2
0
    public void Main()
    {
        Originator originator = new Originator();
        CareTaker  careTaker  = new CareTaker();


        originator.SetState("State #1");
        originator.SetState("State #2");
        careTaker.Add(originator.SaveStateToMemento());
        originator.SetState("State #3");
        careTaker.Add(originator.SaveStateToMemento());
        originator.SetState("State #4");

        Console.WriteLine("Current State: " + originator.GetState());
        originator.GetStateFromMemento(careTaker.Get(0));
        Console.WriteLine("First saved State: " + originator.GetState());
        originator.GetStateFromMemento(careTaker.Get(1));
        Console.WriteLine("Second saved State: " + originator.GetState());
    }
Beispiel #3
0
        static void Main()
        {
            Originator orig = new Originator();

            // Save the state
            Memento.Classic.Memento savedState = orig.GetState();

            orig.SomeOperationThatChangesState();

            // Restore the state
            orig.SetState(savedState);
        }
Beispiel #4
0
 public void ReturnItem()
 {
     originator.GetStateFromMemento(careTaker.Get());
     item = originator.GetState();
 }
Beispiel #5
0
 public SavedState GetState()
 {
     m_originator.RestoreToMemento(m_carTaker.Get(1));
     return(m_originator.GetState());
 }
 internal Memento(Originator o)
 {
     state = o.GetState();
 }