class Memento public string State get private set public Memento strin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Memento
{
public string State { get; private set;}
public Memento(string state)
{
this.State = state;
}
}
class Caretaker
{
public Memento Memento { get; set; }
}
class Originator
{
public string State { get; set; }
public void SetMemento(Memento memento)
{
State = memento.State;
}
public Memento CreateMemento()
{
return new Memento(State);
}
}