forked from EdisonTalk/DesignPattern.Samples.CSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrototypeManager.cs
46 lines (39 loc) · 1.08 KB
/
PrototypeManager.cs
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
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EDC.DesignPattern.Prototype
{
public class PrototypeManager
{
private Dictionary<string, OfficeDocument> dictOD = new Dictionary<string, OfficeDocument>();
public static PrototypeManager GetInstance()
{
return Nested.instance;
}
class Nested
{
static Nested() { }
internal static readonly PrototypeManager instance = new PrototypeManager();
}
private PrototypeManager()
{
dictOD.Add("FAR", new FAR());
dictOD.Add("SRS", new SRS());
}
public void AddOfficeDocument(string key, OfficeDocument doc)
{
dictOD.Add(key, doc);
}
public OfficeDocument GetOfficeDocumentByKey(string key)
{
key = key.ToUpper();
if (!dictOD.ContainsKey(key))
{
return null;
}
return dictOD[key].Clone();
}
}
}