forked from WeihanLi/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (32 loc) · 1.23 KB
/
Program.cs
File metadata and controls
40 lines (32 loc) · 1.23 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
namespace PrototypePattern
{
internal class Program
{
public static void Main(string[] args)
{
#region shallow copy
var resume = new SimpleResume();
resume.SetPersonalInfo("小明", "xiaoming@abc.xyz");
resume.SetWorkExperience("xxx公司", "1990~2000");
resume.Display();
var resume1 = (SimpleResume)resume.Clone();
resume1.SetWorkExperience("xxx企业", "1998~1999");
resume1.Display();
var resume2 = (SimpleResume)resume.Clone();
resume2.SetPersonalInfo("xiaohong", "xiaohong@abc.xyz");
resume2.Display();
#endregion shallow copy
#region deep copy
var complexResume = new ComplexResume();
complexResume.SetPersonalInfo("xiaoming", "xiaoming@abc.xyz");
complexResume.SetWorkExperience("xiaomingTecch", "2001~2005");
complexResume.Show();
var complexResume1 = (ComplexResume)complexResume.Clone();
complexResume1.SetPersonalInfo("xiaohong", "xiaohong@abc.xyz");
complexResume1.Show();
#endregion deep copy
Console.ReadLine();
}
}
}