Example #1
0
        public void Run()
        {
            State s = new State();
            s.A = "a";
            Originator o = new Originator(s);

            o.Show();

            Mementor m = o.CraeteMementor();

            CareTaker c = new CareTaker();
            c.Add(m);

            s.A = "b";
            o.ChangeStatus(s);

            o.Show();

            Mementor tm = (Mementor)c.Restore();

            o.SetState(tm);
            o.Show();
        }
Example #2
0
 public Mementor(State st)
 {
     this.state = (State)st.Clone();
 }
Example #3
0
        public object Clone()
        {
            State state = new State();
            state.A = a;

            return state;
        }
Example #4
0
 public void SetState(Mementor m)
 {
     this.state = m._State;
 }
Example #5
0
 public void ChangeStatus(State s)
 {
     this.state = s;
 }
Example #6
0
 public Originator(State st)
 {
     this.state = (State)st.Clone();
 }