首页 > 代码库 > DesignPattern_Behavioral_Memento

DesignPattern_Behavioral_Memento

void Main(){    Product product = new Product{Name="A"};    Director director = new Director();    director.Memento=product.Save();    product.Load(director.Memento);}class Product{    public string Name { get; set; }    public Memento Save(){        return new Memento{Name=Name};    }    public void Load(Memento m){        Name=m.Name;    }}class Memento{    public string Name { get; set; }}class Director{    public Memento Memento { get; set; }}

 

DesignPattern_Behavioral_Memento