场景
备忘配置文件,实现配置文件的撤销和重做操作
实现代码
配置文件类型
1 | namespace DesignPatterns.Memento |
配置拥有者类
1 | namespace DesignPatterns.Memento |
配置备忘类
1 | namespace DesignPatterns.Memento |
配置管理者
1 | namespace DesignPatterns.Memento |
相关调用
1 | Original original = new Original(); |
Out:1
2
3
4
5
6
7
8
9
10
11
12
13
14Ip: 192.168.1.1, Port: 3000
Ip: 192.168.2.1, Port: 1000
Ip: 192.168.1.2, Port: 6000
Ip: 192.168.1.1, Port: 5000
---------------------
Ip: 192.168.1.2, Port: 6000
Ip: 192.168.2.1, Port: 1000
Ip: 192.168.1.1, Port: 3000
Ip: 192.168.1.127, Port: 5000
----------------
Ip: 192.168.1.1, Port: 3000
Ip: 192.168.2.1, Port: 1000
Ip: 192.168.1.2, Port: 6000
Ip: 192.168.1.1, Port: 5000