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); }
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()); }
static void Main() { Originator orig = new Originator(); // Save the state Memento.Classic.Memento savedState = orig.GetState(); orig.SomeOperationThatChangesState(); // Restore the state orig.SetState(savedState); }
public void ReturnItem() { originator.GetStateFromMemento(careTaker.Get()); item = originator.GetState(); }
public SavedState GetState() { m_originator.RestoreToMemento(m_carTaker.Get(1)); return(m_originator.GetState()); }
internal Memento(Originator o) { state = o.GetState(); }