├── DoFactory.GangOfFour 4.5.sln
├── DoFactory.GangOfFour 4.5.v11.suo
├── DoFactory.GangOfFour.Abstract.NETOptimized
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Abstract.NETOptimized.csproj
├── DoFactory.GangOfFour.Abstract.NETOptimized.csproj.user
├── MainApp.cs
├── app.config
├── bin
│ └── Debug
│ │ ├── DoFactory.GangOfFour.Abstract.NETOptimized.exe.config
│ │ ├── DoFactory.GangOfFour.Abstract.NETOptimized.vshost.exe
│ │ └── DoFactory.GangOfFour.Abstract.NETOptimized.vshost.exe.config
└── obj
│ └── Debug
│ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ └── DoFactory.GangOfFour.Abstract.NETOptimized.csproj.FileListAbsolute.txt
├── DoFactory.GangOfFour.Abstract.Structural
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Abstract.Structural.csproj
├── DoFactory.GangOfFour.Abstract.Structural.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Adapter.Structural
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Adapter.Structural.csproj
├── DoFactory.GangOfFour.Adapter.Structural.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Builder.RealWorld
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Builder.RealWorld.csproj
├── DoFactory.GangOfFour.Builder.RealWorld.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Command.NETOptimized
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Command.NETOptimized.csproj
├── DoFactory.GangOfFour.Command.NETOptimized.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Composite.Structural
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Composite.Structural.csproj
├── DoFactory.GangOfFour.Composite.Structural.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Facade.NETOptimized
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Facade.NETOptimized.csproj
├── DoFactory.GangOfFour.Facade.NETOptimized.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Factory.Structural
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Factory.Structural.csproj
├── DoFactory.GangOfFour.Factory.Structural.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Interpreter.NETOptimized
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Interpreter.NETOptimized.csproj
├── DoFactory.GangOfFour.Interpreter.NETOptimized.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Interpreter.Structural
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Interpreter.Structural.csproj
├── DoFactory.GangOfFour.Interpreter.Structural.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Mediator.Structural
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Mediator.Structural.csproj
├── DoFactory.GangOfFour.Mediator.Structural.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Observer.RealWorld
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Observer.RealWorld.csproj
├── DoFactory.GangOfFour.Observer.RealWorld.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.Proxy.NETOptimized
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.Proxy.NETOptimized.csproj
├── DoFactory.GangOfFour.Proxy.NETOptimized.csproj.user
├── MainApp.cs
├── app.config
└── obj
│ └── Debug
│ └── DesignTimeResolveAssemblyReferencesInput.cache
├── DoFactory.GangOfFour.State.RealWorld
├── App.ico
├── AssemblyInfo.cs
├── DoFactory.GangOfFour.State.RealWorld.csproj
├── DoFactory.GangOfFour.State.RealWorld.csproj.user
└── app.config
├── Gang of Four Design Patterns 4.5.pdf
├── Getting Started 4.5.pdf
├── Head First Design Patterns 4.5.pdf
├── License.txt
├── Patterns In Action 4.5.pdf
├── README.TXT
├── README.md
├── Spark 4.5.pdf
└── db1.mdb
/DoFactory.GangOfFour 4.5.v11.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour 4.5.v11.suo
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.NETOptimized/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.NETOptimized/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/DoFactory.GangOfFour.Abstract.NETOptimized.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {0C486589-BCDD-432F-97FA-757768AF21BD}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Abstract.NETOptimized
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Abstract.NETOptimized
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/DoFactory.GangOfFour.Abstract.NETOptimized.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DoFactory.GangOfFour.Abstract.NETOptimized
5 | {
6 | ///
7 | /// MainApp startup class for .NET optimized
8 | /// Abstract Factory Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | public static void Main()
16 | {
17 | // Create and run the African animal world
18 | var africa = new AnimalWorld();
19 | africa.RunFoodChain();
20 |
21 | // Create and run the American animal world
22 | var america = new AnimalWorld();
23 | america.RunFoodChain();
24 |
25 | // Wait for user input
26 | Console.ReadKey();
27 | }
28 | }
29 |
30 | ///
31 | /// The 'AbstractFactory' interface.
32 | ///
33 | interface IContinentFactory
34 | {
35 | IHerbivore CreateHerbivore();
36 | ICarnivore CreateCarnivore();
37 | }
38 |
39 | ///
40 | /// The 'ConcreteFactory1' class.
41 | ///
42 | class Africa : IContinentFactory
43 | {
44 | public IHerbivore CreateHerbivore()
45 | {
46 | return new Wildebeest();
47 | }
48 |
49 | public ICarnivore CreateCarnivore()
50 | {
51 | return new Lion();
52 | }
53 | }
54 |
55 | ///
56 | /// The 'ConcreteFactory2' class.
57 | ///
58 | class America : IContinentFactory
59 | {
60 | public IHerbivore CreateHerbivore()
61 | {
62 | return new Bison();
63 | }
64 |
65 | public ICarnivore CreateCarnivore()
66 | {
67 | return new Wolf();
68 | }
69 | }
70 |
71 | ///
72 | /// The 'AbstractProductA' interface
73 | ///
74 | interface IHerbivore
75 | {
76 | }
77 |
78 | ///
79 | /// The 'AbstractProductB' interface
80 | ///
81 | interface ICarnivore
82 | {
83 | void Eat(IHerbivore h);
84 | }
85 |
86 | ///
87 | /// The 'ProductA1' class
88 | ///
89 | class Wildebeest : IHerbivore
90 | {
91 | }
92 |
93 | ///
94 | /// The 'ProductB1' class
95 | ///
96 | class Lion : ICarnivore
97 | {
98 | public void Eat(IHerbivore h)
99 | {
100 | // Eat Wildebeest
101 | Console.WriteLine(this.GetType().Name +
102 | " eats " + h.GetType().Name);
103 | }
104 | }
105 |
106 | ///
107 | /// The 'ProductA2' class
108 | ///
109 | class Bison : IHerbivore
110 | {
111 | }
112 |
113 | ///
114 | /// The 'ProductB2' class
115 | ///
116 | class Wolf : ICarnivore
117 | {
118 | public void Eat(IHerbivore h)
119 | {
120 | // Eat Bison
121 | Console.WriteLine(this.GetType().Name +
122 | " eats " + h.GetType().Name);
123 | }
124 | }
125 |
126 | ///
127 | /// The 'Client' interface
128 | ///
129 | interface IAnimalWorld
130 | {
131 | void RunFoodChain();
132 | }
133 |
134 | ///
135 | /// The 'Client' class
136 | ///
137 | class AnimalWorld : IAnimalWorld where T : IContinentFactory, new()
138 | {
139 | IHerbivore herbivore;
140 | ICarnivore carnivore;
141 | T factory;
142 |
143 | ///
144 | /// Contructor of Animalworld
145 | ///
146 | public AnimalWorld()
147 | {
148 | // Create new continent factory
149 | factory = new T();
150 |
151 | // Factory creates carnivores and herbivores
152 | carnivore = factory.CreateCarnivore();
153 | herbivore = factory.CreateHerbivore();
154 | }
155 |
156 | ///
157 | /// Runs the foodchain: carnivores are eating herbivores.
158 | ///
159 | public void RunFoodChain()
160 | {
161 | carnivore.Eat(herbivore);
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/bin/Debug/DoFactory.GangOfFour.Abstract.NETOptimized.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/bin/Debug/DoFactory.GangOfFour.Abstract.NETOptimized.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.NETOptimized/bin/Debug/DoFactory.GangOfFour.Abstract.NETOptimized.vshost.exe
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/bin/Debug/DoFactory.GangOfFour.Abstract.NETOptimized.vshost.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.NETOptimized/obj/Debug/DoFactory.GangOfFour.Abstract.NETOptimized.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\shubhamp.GIST\Downloads\PRO_.NET_Design_Pattern_Framework_4.5_Downloadly.ir\PRO .NET Design Pattern Framework 4.5\Gang Of Four\DoFactory.GangOfFour.Abstract.NETOptimized\bin\Debug\DoFactory.GangOfFour.Abstract.NETOptimized.exe.config
2 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.Structural/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.Structural/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/DoFactory.GangOfFour.Abstract.Structural.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {9B109D29-D245-40BB-B0D2-5EDFB50C781F}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Abstract.Structural
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Abstract.Structural
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/DoFactory.GangOfFour.Abstract.Structural.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DoFactory.GangOfFour.Abstract.Structural
4 | {
5 | ///
6 | /// MainApp startup class for Structural
7 | /// Abstract Factory Design Pattern.
8 | ///
9 | class MainApp
10 | {
11 | ///
12 | /// Entry point into console application.
13 | ///
14 | public static void Main()
15 | {
16 | // Abstract factory #1
17 | AbstractFactory factory1 = new ConcreteFactory1();
18 | Client client1 = new Client(factory1);
19 | client1.Run();
20 |
21 | // Abstract factory #2
22 | AbstractFactory factory2 = new ConcreteFactory2();
23 | Client client2 = new Client(factory2);
24 | client2.Run();
25 |
26 | // Wait for user input
27 | Console.ReadKey();
28 | }
29 | }
30 |
31 | ///
32 | /// The 'AbstractFactory' abstract class
33 | ///
34 | abstract class AbstractFactory
35 | {
36 | public abstract AbstractProductA CreateProductA();
37 | public abstract AbstractProductB CreateProductB();
38 | }
39 |
40 |
41 | ///
42 | /// The 'ConcreteFactory1' class
43 | ///
44 | class ConcreteFactory1 : AbstractFactory
45 | {
46 | public override AbstractProductA CreateProductA()
47 | {
48 | return new ProductA1();
49 | }
50 | public override AbstractProductB CreateProductB()
51 | {
52 | return new ProductB1();
53 | }
54 | }
55 |
56 | ///
57 | /// The 'ConcreteFactory2' class
58 | ///
59 | class ConcreteFactory2 : AbstractFactory
60 | {
61 | public override AbstractProductA CreateProductA()
62 | {
63 | return new ProductA2();
64 | }
65 | public override AbstractProductB CreateProductB()
66 | {
67 | return new ProductB2();
68 | }
69 | }
70 |
71 | ///
72 | /// The 'AbstractProductA' abstract class
73 | ///
74 | abstract class AbstractProductA
75 | {
76 | }
77 |
78 | ///
79 | /// The 'AbstractProductB' abstract class
80 | ///
81 | abstract class AbstractProductB
82 | {
83 | public abstract void Interact(AbstractProductA a);
84 | }
85 |
86 |
87 | ///
88 | /// The 'ProductA1' class
89 | ///
90 | class ProductA1 : AbstractProductA
91 | {
92 | }
93 |
94 | ///
95 | /// The 'ProductB1' class
96 | ///
97 | class ProductB1 : AbstractProductB
98 | {
99 | public override void Interact(AbstractProductA a)
100 | {
101 | Console.WriteLine(this.GetType().Name +
102 | " interacts with " + a.GetType().Name);
103 | }
104 | }
105 |
106 | ///
107 | /// The 'ProductA2' class
108 | ///
109 | class ProductA2 : AbstractProductA
110 | {
111 | }
112 |
113 | ///
114 | /// The 'ProductB2' class
115 | ///
116 | class ProductB2 : AbstractProductB
117 | {
118 | public override void Interact(AbstractProductA a)
119 | {
120 | Console.WriteLine(this.GetType().Name +
121 | " interacts with " + a.GetType().Name);
122 | }
123 | }
124 |
125 | ///
126 | /// The 'Client' class. Interaction environment for the products.
127 | ///
128 | class Client
129 | {
130 | private AbstractProductA abstractProductA;
131 | private AbstractProductB abstractProductB;
132 |
133 | // Constructor
134 | public Client(AbstractFactory factory)
135 | {
136 | abstractProductB = factory.CreateProductB();
137 | abstractProductA = factory.CreateProductA();
138 | }
139 |
140 | public void Run()
141 | {
142 | abstractProductB.Interact(abstractProductA);
143 | }
144 | }
145 | }
146 |
147 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Abstract.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Abstract.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Adapter.Structural/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Adapter.Structural/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/DoFactory.GangOfFour.Adapter.Structural.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {17209C29-276A-4519-B5DB-CD84FF4F8DA3}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Adapter.Structural
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Adapter.Structural
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/DoFactory.GangOfFour.Adapter.Structural.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DoFactory.GangOfFour.Adapter.Structural
4 | {
5 | ///
6 | /// MainApp startup class for Structural
7 | /// Adapter Design Pattern.
8 | ///
9 | class MainApp
10 | {
11 | ///
12 | /// Entry point into console application.
13 | ///
14 | static void Main()
15 | {
16 | // Create adapter and place a request
17 | Target target = new Adapter();
18 | target.Request();
19 |
20 | // Wait for user
21 | Console.ReadKey();
22 | }
23 | }
24 |
25 | ///
26 | /// The 'Target' class
27 | ///
28 | class Target
29 | {
30 | public virtual void Request()
31 | {
32 | Console.WriteLine("Called Target Request()");
33 | }
34 | }
35 |
36 | ///
37 | /// The 'Adapter' class
38 | ///
39 | class Adapter : Target
40 | {
41 | private Adaptee adaptee = new Adaptee();
42 |
43 | public override void Request()
44 | {
45 | // Possibly do some other work
46 | // and then call SpecificRequest
47 | adaptee.SpecificRequest();
48 | }
49 | }
50 |
51 | ///
52 | /// The 'Adaptee' class
53 | ///
54 | class Adaptee
55 | {
56 | public void SpecificRequest()
57 | {
58 | Console.WriteLine("Called SpecificRequest()");
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Adapter.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Adapter.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Builder.RealWorld/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Builder.RealWorld/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/DoFactory.GangOfFour.Builder.RealWorld.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {49F613E0-AD2A-4C60-8AEC-A9511F3677CD}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Builder.RealWorld
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Builder.RealWorld
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/DoFactory.GangOfFour.Builder.RealWorld.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DoFactory.GangOfFour.Builder.RealWorld
5 | {
6 | ///
7 | /// MainApp startup class for Real-World
8 | /// Builder Design Pattern.
9 | ///
10 | public class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | public static void Main()
16 | {
17 | VehicleBuilder builder;
18 |
19 | // Create shop with vehicle builders
20 | Shop shop = new Shop();
21 |
22 | // Construct and display vehicles
23 | builder = new ScooterBuilder();
24 | shop.Construct(builder);
25 | builder.Vehicle.Show();
26 |
27 | builder = new CarBuilder();
28 | shop.Construct(builder);
29 | builder.Vehicle.Show();
30 |
31 | builder = new MotorCycleBuilder();
32 | shop.Construct(builder);
33 | builder.Vehicle.Show();
34 |
35 | // Wait for user
36 | Console.ReadKey();
37 | }
38 | }
39 |
40 | ///
41 | /// The 'Director' class
42 | ///
43 | class Shop
44 | {
45 | // Builder uses a complex series of steps
46 | public void Construct(VehicleBuilder vehicleBuilder)
47 | {
48 | vehicleBuilder.BuildFrame();
49 | vehicleBuilder.BuildEngine();
50 | vehicleBuilder.BuildWheels();
51 | vehicleBuilder.BuildDoors();
52 | }
53 | }
54 |
55 | ///
56 | /// The 'Builder' abstract class
57 | ///
58 | abstract class VehicleBuilder
59 | {
60 | protected Vehicle vehicle;
61 |
62 | // Gets vehicle instance
63 | public Vehicle Vehicle
64 | {
65 | get { return vehicle; }
66 | }
67 |
68 | // Abstract build methods
69 | public abstract void BuildFrame();
70 | public abstract void BuildEngine();
71 | public abstract void BuildWheels();
72 | public abstract void BuildDoors();
73 | }
74 |
75 | ///
76 | /// The 'ConcreteBuilder1' class
77 | ///
78 | class MotorCycleBuilder : VehicleBuilder
79 | {
80 | public MotorCycleBuilder()
81 | {
82 | vehicle = new Vehicle("MotorCycle");
83 | }
84 |
85 | public override void BuildFrame()
86 | {
87 | vehicle["frame"] = "MotorCycle Frame";
88 | }
89 |
90 | public override void BuildEngine()
91 | {
92 | vehicle["engine"] = "500 cc";
93 | }
94 |
95 | public override void BuildWheels()
96 | {
97 | vehicle["wheels"] = "2";
98 | }
99 |
100 | public override void BuildDoors()
101 | {
102 | vehicle["doors"] = "0";
103 | }
104 | }
105 |
106 |
107 | ///
108 | /// The 'ConcreteBuilder2' class
109 | ///
110 | class CarBuilder : VehicleBuilder
111 | {
112 | public CarBuilder()
113 | {
114 | vehicle = new Vehicle("Car");
115 | }
116 |
117 | public override void BuildFrame()
118 | {
119 | vehicle["frame"] = "Car Frame";
120 | }
121 |
122 | public override void BuildEngine()
123 | {
124 | vehicle["engine"] = "2500 cc";
125 | }
126 |
127 | public override void BuildWheels()
128 | {
129 | vehicle["wheels"] = "4";
130 | }
131 |
132 | public override void BuildDoors()
133 | {
134 | vehicle["doors"] = "4";
135 | }
136 | }
137 |
138 | ///
139 | /// The 'ConcreteBuilder3' class
140 | ///
141 | class ScooterBuilder : VehicleBuilder
142 | {
143 | public ScooterBuilder()
144 | {
145 | vehicle = new Vehicle("Scooter");
146 | }
147 |
148 | public override void BuildFrame()
149 | {
150 | vehicle["frame"] = "Scooter Frame";
151 | }
152 |
153 | public override void BuildEngine()
154 | {
155 | vehicle["engine"] = "50 cc";
156 | }
157 |
158 | public override void BuildWheels()
159 | {
160 | vehicle["wheels"] = "2";
161 | }
162 |
163 | public override void BuildDoors()
164 | {
165 | vehicle["doors"] = "0";
166 | }
167 | }
168 |
169 | ///
170 | /// The 'Product' class
171 | ///
172 | class Vehicle
173 | {
174 | string vehicleType;
175 | Dictionary parts = new Dictionary();
176 |
177 | // Constructor
178 | public Vehicle(string vehicleType)
179 | {
180 | this.vehicleType = vehicleType;
181 | }
182 |
183 | // Indexer
184 | public string this[string key]
185 | {
186 | get { return parts[key]; }
187 | set { parts[key] = value; }
188 | }
189 |
190 | public void Show()
191 | {
192 | Console.WriteLine("\n---------------------------");
193 | Console.WriteLine("Vehicle Type: {0}", vehicleType);
194 | Console.WriteLine(" Frame : {0}", parts["frame"]);
195 | Console.WriteLine(" Engine : {0}", parts["engine"]);
196 | Console.WriteLine(" #Wheels: {0}", parts["wheels"]);
197 | Console.WriteLine(" #Doors : {0}", parts["doors"]);
198 | }
199 | }
200 | }
201 |
202 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Builder.RealWorld/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Builder.RealWorld/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Command.NETOptimized/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Command.NETOptimized/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/DoFactory.GangOfFour.Command.NETOptimized.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {12FAEA0A-C32F-4A01-86F3-3BC68E55D5AD}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Command.NETOptimized
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Command.NETOptimized
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/DoFactory.GangOfFour.Command.NETOptimized.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | false
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DoFactory.GangOfFour.Command.NETOptimized
5 | {
6 | ///
7 | /// MainApp startup class for .NET optimized
8 | /// Command Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | static void Main()
16 | {
17 | // Create user and let her compute
18 | var user = new User();
19 |
20 | // Issue several compute commands
21 | user.Compute('+', 100);
22 | user.Compute('-', 50);
23 | user.Compute('*', 10);
24 | user.Compute('/', 2);
25 |
26 | // Undo 4 commands
27 | user.Undo(4);
28 |
29 | // Redo 3 commands
30 | user.Redo(3);
31 |
32 | // Wait for user
33 | Console.ReadKey();
34 | }
35 | }
36 |
37 | ///
38 | /// The 'Command' interface
39 | ///
40 | interface ICommand
41 | {
42 | void Execute();
43 | void UnExecute();
44 | }
45 |
46 | ///
47 | /// The 'ConcreteCommand' class
48 | ///
49 | class CalculatorCommand : ICommand
50 | {
51 | char @operator;
52 | int operand;
53 | Calculator calculator;
54 |
55 | // Constructor
56 | public CalculatorCommand(Calculator calculator, char @operator, int operand)
57 | {
58 | this.calculator = calculator;
59 | this.@operator = @operator;
60 | this.operand = operand;
61 | }
62 |
63 | // Sets operator
64 | public char Operator
65 | {
66 | set { @operator = value; }
67 | }
68 |
69 | // Sets operand
70 | public int Operand
71 | {
72 | set { operand = value; }
73 | }
74 |
75 | // Execute command
76 | public void Execute()
77 | {
78 | calculator.Operation(@operator, operand);
79 | }
80 |
81 | // Unexecute command
82 | public void UnExecute()
83 | {
84 | calculator.Operation(Undo(@operator), operand);
85 | }
86 |
87 | // Return opposite operator for given operator
88 | private char Undo(char @operator)
89 | {
90 | switch (@operator)
91 | {
92 | case '+': return '-';
93 | case '-': return '+';
94 | case '*': return '/';
95 | case '/': return '*';
96 | default: throw new
97 | ArgumentException("@operator");
98 | }
99 | }
100 | }
101 |
102 | ///
103 | /// The 'Receiver' class
104 | ///
105 | class Calculator
106 | {
107 | int current = 0;
108 |
109 | // Perform operation for given operator and operand
110 | public void Operation(char @operator, int operand)
111 | {
112 | switch (@operator)
113 | {
114 | case '+': current += operand; break;
115 | case '-': current -= operand; break;
116 | case '*': current *= operand; break;
117 | case '/': current /= operand; break;
118 | }
119 | Console.WriteLine(
120 | "Current value = {0,3} (following {1} {2})",
121 | current, @operator, operand);
122 | }
123 | }
124 |
125 | ///
126 | /// The 'Invoker' class
127 | ///
128 | class User
129 | {
130 | Calculator calculator = new Calculator();
131 | List commands = new List();
132 | int current = 0;
133 |
134 | // Redo original commands
135 | public void Redo(int levels)
136 | {
137 | Console.WriteLine("\n---- Redo {0} levels ", levels);
138 |
139 | // Perform redo operations
140 | for (int i = 0; i < levels; i++)
141 | {
142 | if (current < commands.Count - 1)
143 | {
144 | commands[current++].Execute();
145 | }
146 | }
147 | }
148 |
149 | // Undo prior commands
150 | public void Undo(int levels)
151 | {
152 | Console.WriteLine("\n---- Undo {0} levels ", levels);
153 |
154 | // Perform undo operations
155 | for (int i = 0; i < levels; i++)
156 | {
157 | if (current > 0)
158 | {
159 | commands[--current].UnExecute();
160 | }
161 | }
162 | }
163 |
164 | // Compute new value given operator and operand
165 | public void Compute(char @operator, int operand)
166 | {
167 | // Create command operation and execute it
168 | var command = new CalculatorCommand(calculator, @operator, operand);
169 | command.Execute();
170 |
171 | // Add command to undo list
172 | commands.Add(command);
173 | current++;
174 | }
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Command.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Command.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Composite.Structural/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Composite.Structural/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/DoFactory.GangOfFour.Composite.Structural.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {E71736AE-3CD3-42B2-85AC-5F35B015A6A7}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Composite.Structural
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Composite.Structural
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/DoFactory.GangOfFour.Composite.Structural.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DoFactory.GangOfFour.Composite.Structural
5 | {
6 | ///
7 | /// MainApp startup class for Structural
8 | /// Composite Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | static void Main()
16 | {
17 | // Create a tree structure
18 | Composite root = new Composite("root");
19 | root.Add(new Leaf("Leaf A"));
20 | root.Add(new Leaf("Leaf B"));
21 |
22 | Composite comp = new Composite("Composite X");
23 | comp.Add(new Leaf("Leaf XA"));
24 | comp.Add(new Leaf("Leaf XB"));
25 |
26 | root.Add(comp);
27 | root.Add(new Leaf("Leaf C"));
28 |
29 | // Add and remove a leaf
30 | Leaf leaf = new Leaf("Leaf D");
31 | root.Add(leaf);
32 | root.Remove(leaf);
33 |
34 | // Recursively display tree
35 | root.Display(1);
36 |
37 | // Wait for user
38 | Console.ReadKey();
39 | }
40 | }
41 |
42 | ///
43 | /// The 'Component' abstract class
44 | ///
45 | abstract class Component
46 | {
47 | protected string name;
48 |
49 | // Constructor
50 | public Component(string name)
51 | {
52 | this.name = name;
53 | }
54 |
55 | public abstract void Add(Component c);
56 | public abstract void Remove(Component c);
57 | public abstract void Display(int depth);
58 | }
59 |
60 | ///
61 | /// The 'Composite' class
62 | ///
63 | class Composite : Component
64 | {
65 | List children = new List();
66 |
67 | // Constructor
68 | public Composite(string name)
69 | : base(name)
70 | {
71 | }
72 |
73 | public override void Add(Component component)
74 | {
75 | children.Add(component);
76 | }
77 |
78 | public override void Remove(Component component)
79 | {
80 | children.Remove(component);
81 | }
82 |
83 | public override void Display(int depth)
84 | {
85 | Console.WriteLine(new String('-', depth) + name);
86 |
87 | // Recursively display child nodes
88 | foreach (Component component in children)
89 | {
90 | component.Display(depth + 2);
91 | }
92 | }
93 | }
94 |
95 | ///
96 | /// The 'Leaf' class
97 | ///
98 | class Leaf : Component
99 | {
100 | // Constructor
101 | public Leaf(string name)
102 | : base(name)
103 | {
104 | }
105 |
106 | public override void Add(Component c)
107 | {
108 | Console.WriteLine("Cannot add to a leaf");
109 | }
110 |
111 | public override void Remove(Component c)
112 | {
113 | Console.WriteLine("Cannot remove from a leaf");
114 | }
115 |
116 | public override void Display(int depth)
117 | {
118 | Console.WriteLine(new String('-', depth) + name);
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Composite.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Composite.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Facade.NETOptimized/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Facade.NETOptimized/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/DoFactory.GangOfFour.Facade.NETOptimized.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {F69710A2-A145-46DF-8AF3-0945917C87BB}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Facade.NETOptimized
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Facade.NETOptimized
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/DoFactory.GangOfFour.Facade.NETOptimized.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DoFactory.GangOfFour.Facade.NETOptimized
4 | {
5 | ///
6 | /// MainApp startup class for .NET optimized
7 | /// Facade Design Pattern.
8 | ///
9 | class MainApp
10 | {
11 | ///
12 | /// Entry point into console application.
13 | ///
14 | static void Main()
15 | {
16 | // Facade
17 | var mortgage = new Mortgage();
18 |
19 | // Evaluate mortgage eligibility for customer
20 | var customer = new Customer { Name = "Ann McKinsey" };
21 | bool eligible = mortgage.IsEligible(customer, 125000);
22 |
23 | Console.WriteLine("\n" + customer.Name +
24 | " has been " + (eligible ? "Approved" : "Rejected"));
25 |
26 | // Wait for user
27 | Console.ReadKey();
28 | }
29 | }
30 |
31 | ///
32 | /// The 'Subsystem ClassA' class
33 | ///
34 | class Bank
35 | {
36 | public bool HasSufficientSavings(Customer c, int amount)
37 | {
38 | Console.WriteLine("Check bank for " + c.Name);
39 | return true;
40 | }
41 | }
42 |
43 | ///
44 | /// The 'Subsystem ClassB' class
45 | ///
46 | class Credit
47 | {
48 | public bool HasGoodCredit(Customer c)
49 | {
50 | Console.WriteLine("Check credit for " + c.Name);
51 | return true;
52 | }
53 | }
54 |
55 | ///
56 | /// The 'Subsystem ClassC' class
57 | ///
58 | class Loan
59 | {
60 | public bool HasNoBadLoans(Customer c)
61 | {
62 | Console.WriteLine("Check loans for " + c.Name);
63 | return true;
64 | }
65 | }
66 |
67 | ///
68 | /// The 'Facade' class
69 | ///
70 | class Mortgage
71 | {
72 | Bank bank = new Bank();
73 | Loan loan = new Loan();
74 | Credit credit = new Credit();
75 |
76 | public bool IsEligible(Customer cust, int amount)
77 | {
78 | Console.WriteLine("{0} applies for {1:C} loan\n",
79 | cust.Name, amount);
80 |
81 | bool eligible = true;
82 |
83 | // Check creditworthyness of applicant
84 | if (!bank.HasSufficientSavings(cust, amount))
85 | {
86 | eligible = false;
87 | }
88 | else if (!loan.HasNoBadLoans(cust))
89 | {
90 | eligible = false;
91 | }
92 | else if (!credit.HasGoodCredit(cust))
93 | {
94 | eligible = false;
95 | }
96 |
97 | return eligible;
98 | }
99 | }
100 |
101 | ///
102 | /// Customer class
103 | ///
104 | class Customer
105 | {
106 | // Gets or sets the name
107 | public string Name { get; set; }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Facade.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Facade.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Factory.Structural/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Factory.Structural/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/DoFactory.GangOfFour.Factory.Structural.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {E6DCA618-3F17-4DA1-A29A-2018E99E3BAE}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Factory.Structural
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Factory.Structural
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/DoFactory.GangOfFour.Factory.Structural.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | false
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DoFactory.GangOfFour.Factory.Structural
4 | {
5 | ///
6 | /// MainApp startup class for Structural
7 | /// Factory Method Design Pattern.
8 | ///
9 | class MainApp
10 | {
11 | ///
12 | /// Entry point into console application.
13 | ///
14 | static void Main()
15 | {
16 | // An array of creators
17 | Creator[] creators = new Creator[2];
18 |
19 | creators[0] = new ConcreteCreatorA();
20 | creators[1] = new ConcreteCreatorB();
21 |
22 | // Iterate over creators and create products
23 | foreach (Creator creator in creators)
24 | {
25 | Product product = creator.FactoryMethod();
26 | Console.WriteLine("Created {0}",
27 | product.GetType().Name);
28 | }
29 |
30 | // Wait for user
31 | Console.ReadKey();
32 | }
33 | }
34 |
35 | ///
36 | /// The 'Product' abstract class
37 | ///
38 | abstract class Product
39 | {
40 | }
41 |
42 | ///
43 | /// A 'ConcreteProduct' class
44 | ///
45 | class ConcreteProductA : Product
46 | {
47 | }
48 |
49 | ///
50 | /// A 'ConcreteProduct' class
51 | ///
52 | class ConcreteProductB : Product
53 | {
54 | }
55 |
56 | ///
57 | /// The 'Creator' abstract class
58 | ///
59 | abstract class Creator
60 | {
61 | public abstract Product FactoryMethod();
62 | }
63 |
64 | ///
65 | /// A 'ConcreteCreator' class
66 | ///
67 | class ConcreteCreatorA : Creator
68 | {
69 | public override Product FactoryMethod()
70 | {
71 | return new ConcreteProductA();
72 | }
73 | }
74 |
75 | ///
76 | /// A 'ConcreteCreator' class
77 | ///
78 | class ConcreteCreatorB : Creator
79 | {
80 | public override Product FactoryMethod()
81 | {
82 | return new ConcreteProductB();
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Factory.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Factory.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Interpreter.NETOptimized/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Interpreter.NETOptimized/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/DoFactory.GangOfFour.Interpreter.NETOptimized.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {64F572E6-44ED-4161-B517-808F4C103C08}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Interpreter.NETOptimized
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Interpreter.NETOptimized
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/DoFactory.GangOfFour.Interpreter.NETOptimized.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | false
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DoFactory.GangOfFour.Interpreter.NETOptimized
5 | {
6 | ///
7 | /// MainApp startup class for .NET optimized
8 | /// Interpreter Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | static void Main()
16 | {
17 | // Construct the 'parse tree'
18 | var tree = new List
19 | {
20 | new ThousandExpression(),
21 | new HundredExpression(),
22 | new TenExpression(),
23 | new OneExpression()
24 | };
25 |
26 | // Create the context (i.e. roman value)
27 | string roman = "MCMXXVIII";
28 | var context = new Context { Input = roman };
29 |
30 | // Interpret
31 | tree.ForEach(e => e.Interpret(context));
32 |
33 | Console.WriteLine("{0} = {1}", roman, context.Output);
34 |
35 | // Wait for user
36 | Console.ReadKey();
37 | }
38 | }
39 |
40 | ///
41 | /// The 'Context' class
42 | ///
43 | class Context
44 | {
45 | public string Input { get; set; }
46 | public int Output { get; set; }
47 | }
48 |
49 | ///
50 | /// The 'AbstractExpression' abstract class
51 | ///
52 | abstract class Expression
53 | {
54 | public void Interpret(Context context)
55 | {
56 | if (context.Input.Length == 0)
57 | return;
58 |
59 | if (context.Input.StartsWith(Nine()))
60 | {
61 | context.Output += (9 * Multiplier());
62 | context.Input = context.Input.Substring(2);
63 | }
64 | else if (context.Input.StartsWith(Four()))
65 | {
66 | context.Output += (4 * Multiplier());
67 | context.Input = context.Input.Substring(2);
68 | }
69 | else if (context.Input.StartsWith(Five()))
70 | {
71 | context.Output += (5 * Multiplier());
72 | context.Input = context.Input.Substring(1);
73 | }
74 |
75 | while (context.Input.StartsWith(One()))
76 | {
77 | context.Output += (1 * Multiplier());
78 | context.Input = context.Input.Substring(1);
79 | }
80 | }
81 |
82 | public abstract string One();
83 | public abstract string Four();
84 | public abstract string Five();
85 | public abstract string Nine();
86 | public abstract int Multiplier();
87 | }
88 |
89 | ///
90 | /// A 'TerminalExpression' class
91 | ///
92 | /// Thousand checks for the Roman Numeral M
93 | ///
94 | ///
95 | class ThousandExpression : Expression
96 | {
97 | public override string One() { return "M"; }
98 | public override string Four() { return " "; }
99 | public override string Five() { return " "; }
100 | public override string Nine() { return " "; }
101 | public override int Multiplier() { return 1000; }
102 | }
103 |
104 | ///
105 | /// A 'TerminalExpression' class
106 | ///
107 | /// Hundred checks C, CD, D or CM
108 | ///
109 | ///
110 | class HundredExpression : Expression
111 | {
112 | public override string One() { return "C"; }
113 | public override string Four() { return "CD"; }
114 | public override string Five() { return "D"; }
115 | public override string Nine() { return "CM"; }
116 | public override int Multiplier() { return 100; }
117 | }
118 |
119 | ///
120 | /// A 'TerminalExpression' class
121 | ///
122 | /// Ten checks for X, XL, L and XC
123 | ///
124 | ///
125 | class TenExpression : Expression
126 | {
127 | public override string One() { return "X"; }
128 | public override string Four() { return "XL"; }
129 | public override string Five() { return "L"; }
130 | public override string Nine() { return "XC"; }
131 | public override int Multiplier() { return 10; }
132 | }
133 |
134 | ///
135 | /// A 'TerminalExpression' class
136 | ///
137 | /// One checks for I, II, III, IV, V, VI, VI, VII, VIII, IX
138 | ///
139 | ///
140 | class OneExpression : Expression
141 | {
142 | public override string One() { return "I"; }
143 | public override string Four() { return "IV"; }
144 | public override string Five() { return "V"; }
145 | public override string Nine() { return "IX"; }
146 | public override int Multiplier() { return 1; }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Interpreter.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Interpreter.Structural/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Interpreter.Structural/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/DoFactory.GangOfFour.Interpreter.Structural.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {510179C8-D9C5-4354-AC6B-63DC23AC2E21}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Interpreter.Structural
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Interpreter.Structural
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/DoFactory.GangOfFour.Interpreter.Structural.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace DoFactory.GangOfFour.Interpreter.Structural
5 | {
6 | ///
7 | /// MainApp startup class for Structural
8 | /// Interpreter Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | static void Main()
16 | {
17 | Context context = new Context();
18 |
19 | // Usually a tree
20 | ArrayList list = new ArrayList();
21 |
22 | // Populate 'abstract syntax tree'
23 | list.Add(new TerminalExpression());
24 | list.Add(new NonterminalExpression());
25 | list.Add(new TerminalExpression());
26 | list.Add(new TerminalExpression());
27 |
28 | // Interpret
29 | foreach (AbstractExpression exp in list)
30 | {
31 | exp.Interpret(context);
32 | }
33 |
34 | // Wait for user
35 | Console.ReadKey();
36 | }
37 | }
38 |
39 | ///
40 | /// The 'Context' class
41 | ///
42 | class Context
43 | {
44 | }
45 |
46 | ///
47 | /// The 'AbstractExpression' abstract class
48 | ///
49 | abstract class AbstractExpression
50 | {
51 | public abstract void Interpret(Context context);
52 | }
53 |
54 | ///
55 | /// The 'TerminalExpression' class
56 | ///
57 | class TerminalExpression : AbstractExpression
58 | {
59 | public override void Interpret(Context context)
60 | {
61 | Console.WriteLine("Called Terminal.Interpret()");
62 | }
63 | }
64 |
65 | ///
66 | /// The 'NonterminalExpression' class
67 | ///
68 | class NonterminalExpression : AbstractExpression
69 | {
70 | public override void Interpret(Context context)
71 | {
72 | Console.WriteLine("Called Nonterminal.Interpret()");
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Interpreter.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Interpreter.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Mediator.Structural/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Mediator.Structural/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/DoFactory.GangOfFour.Mediator.Structural.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {59C0BFA6-6A37-4EE3-A14E-AC81EC422F74}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Mediator.Structural
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Mediator.Structural
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/DoFactory.GangOfFour.Mediator.Structural.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | false
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DoFactory.GangOfFour.Mediator.Structural
4 | {
5 | ///
6 | /// MainApp startup class for Structural
7 | /// Mediator Design Pattern.
8 | ///
9 | class MainApp
10 | {
11 | ///
12 | /// Entry point into console application.
13 | ///
14 | static void Main()
15 | {
16 | ConcreteMediator m = new ConcreteMediator();
17 |
18 | ConcreteColleague1 c1 = new ConcreteColleague1(m);
19 | ConcreteColleague2 c2 = new ConcreteColleague2(m);
20 |
21 | m.Colleague1 = c1;
22 | m.Colleague2 = c2;
23 |
24 | c1.Send("How are you?");
25 | c2.Send("Fine, thanks");
26 |
27 | // Wait for user
28 | Console.ReadKey();
29 | }
30 | }
31 |
32 | ///
33 | /// The 'Mediator' abstract class
34 | ///
35 | abstract class Mediator
36 | {
37 | public abstract void Send(string message,
38 | Colleague colleague);
39 | }
40 |
41 | ///
42 | /// The 'ConcreteMediator' class
43 | ///
44 | class ConcreteMediator : Mediator
45 | {
46 | ConcreteColleague1 colleague1;
47 | ConcreteColleague2 colleague2;
48 |
49 | public ConcreteColleague1 Colleague1
50 | {
51 | set { colleague1 = value; }
52 | }
53 |
54 | public ConcreteColleague2 Colleague2
55 | {
56 | set { colleague2 = value; }
57 | }
58 |
59 | public override void Send(string message, Colleague colleague)
60 | {
61 | if (colleague == colleague1)
62 | {
63 | colleague2.Notify(message);
64 | }
65 | else
66 | {
67 | colleague1.Notify(message);
68 | }
69 | }
70 | }
71 |
72 | ///
73 | /// The 'Colleague' abstract class
74 | ///
75 | abstract class Colleague
76 | {
77 | protected Mediator mediator;
78 |
79 | // Constructor
80 | public Colleague(Mediator mediator)
81 | {
82 | this.mediator = mediator;
83 | }
84 | }
85 |
86 | ///
87 | /// A 'ConcreteColleague' class
88 | ///
89 | class ConcreteColleague1 : Colleague
90 | {
91 | // Constructor
92 | public ConcreteColleague1(Mediator mediator)
93 | : base(mediator)
94 | {
95 | }
96 |
97 | public void Send(string message)
98 | {
99 | mediator.Send(message, this);
100 | }
101 |
102 | public void Notify(string message)
103 | {
104 | Console.WriteLine("Colleague1 gets message: "
105 | + message);
106 | }
107 | }
108 |
109 | ///
110 | /// A 'ConcreteColleague' class
111 | ///
112 | class ConcreteColleague2 : Colleague
113 | {
114 | // Constructor
115 | public ConcreteColleague2(Mediator mediator)
116 | : base(mediator)
117 | {
118 | }
119 |
120 | public void Send(string message)
121 | {
122 | mediator.Send(message, this);
123 | }
124 |
125 | public void Notify(string message)
126 | {
127 | Console.WriteLine("Colleague2 gets message: "
128 | + message);
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Mediator.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Mediator.Structural/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Observer.RealWorld/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Observer.RealWorld/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/DoFactory.GangOfFour.Observer.RealWorld.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {DAF6EA8C-B0D3-4BB5-9996-4587A86590E8}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Observer.RealWorld
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Observer.RealWorld
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/DoFactory.GangOfFour.Observer.RealWorld.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | false
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DoFactory.GangOfFour.Observer.RealWorld
5 | {
6 | ///
7 | /// MainApp startup class for Real-World
8 | /// Observer Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | static void Main()
16 | {
17 | // Create IBM stock and attach investors
18 | IBM ibm = new IBM("IBM", 120.00);
19 | ibm.Attach(new Investor("Sorros"));
20 | ibm.Attach(new Investor("Berkshire"));
21 |
22 | // Fluctuating prices will notify investors
23 | ibm.Price = 120.10;
24 | ibm.Price = 121.00;
25 | ibm.Price = 120.50;
26 | ibm.Price = 120.75;
27 |
28 | // Wait for user
29 | Console.ReadKey();
30 | }
31 | }
32 |
33 | ///
34 | /// The 'Subject' abstract class
35 | ///
36 | abstract class Stock
37 | {
38 | string symbol;
39 | double price;
40 | List investors = new List();
41 |
42 | // Constructor
43 | public Stock(string symbol, double price)
44 | {
45 | this.symbol = symbol;
46 | this.price = price;
47 | }
48 |
49 | public void Attach(IInvestor investor)
50 | {
51 | investors.Add(investor);
52 | }
53 |
54 | public void Detach(IInvestor investor)
55 | {
56 | investors.Remove(investor);
57 | }
58 |
59 | public void Notify()
60 | {
61 | foreach (IInvestor investor in investors)
62 | {
63 | investor.Update(this);
64 | }
65 |
66 | Console.WriteLine("");
67 | }
68 |
69 | // Gets or sets the price
70 | public double Price
71 | {
72 | get { return price; }
73 | set
74 | {
75 | if (price != value)
76 | {
77 | price = value;
78 | Notify();
79 | }
80 | }
81 | }
82 |
83 | // Gets the symbol
84 | public string Symbol
85 | {
86 | get { return symbol; }
87 | }
88 | }
89 |
90 | ///
91 | /// The 'ConcreteSubject' class
92 | ///
93 | class IBM : Stock
94 | {
95 | // Constructor
96 | public IBM(string symbol, double price)
97 | : base(symbol, price)
98 | {
99 | }
100 | }
101 |
102 | ///
103 | /// The 'Observer' interface
104 | ///
105 | interface IInvestor
106 | {
107 | void Update(Stock stock);
108 | }
109 |
110 | ///
111 | /// The 'ConcreteObserver' class
112 | ///
113 | class Investor : IInvestor
114 | {
115 | string name;
116 | Stock stock;
117 |
118 | // Constructor
119 | public Investor(string name)
120 | {
121 | this.name = name;
122 | }
123 |
124 | public void Update(Stock stock)
125 | {
126 | Console.WriteLine("Notified {0} of {1}'s " +
127 | "change to {2:C}", name, stock.Symbol, stock.Price);
128 | }
129 |
130 | // Gets or sets the stock
131 | public Stock Stock
132 | {
133 | get { return stock; }
134 | set { stock = value; }
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Observer.RealWorld/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Observer.RealWorld/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Proxy.NETOptimized/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Proxy.NETOptimized/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/DoFactory.GangOfFour.Proxy.NETOptimized.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {8CE5A3B9-7352-4BD9-95FE-8635202824C5}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.Proxy.NETOptimized
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.Proxy.NETOptimized
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/DoFactory.GangOfFour.Proxy.NETOptimized.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | true
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/MainApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Remoting;
3 |
4 | namespace DoFactory.GangOfFour.Proxy.NETOptimized
5 | {
6 | ///
7 | /// MainApp startup class for .NET optimized
8 | /// Proxy Design Pattern.
9 | ///
10 | class MainApp
11 | {
12 | ///
13 | /// Entry point into console application.
14 | ///
15 | static void Main()
16 | {
17 | // Create math proxy
18 | var proxy = new MathProxy();
19 |
20 | // Do the math
21 | Console.WriteLine("4 + 2 = " + proxy.Add(4, 2));
22 | Console.WriteLine("4 - 2 = " + proxy.Sub(4, 2));
23 | Console.WriteLine("4 * 2 = " + proxy.Mul(4, 2));
24 | Console.WriteLine("4 / 2 = " + proxy.Div(4, 2));
25 |
26 | // Wait for user
27 | Console.ReadKey();
28 | }
29 | }
30 |
31 | ///
32 | /// The 'Subject' interface
33 | ///
34 | public interface IMath
35 | {
36 | double Add(double x, double y);
37 | double Sub(double x, double y);
38 | double Mul(double x, double y);
39 | double Div(double x, double y);
40 | }
41 |
42 | ///
43 | /// The 'RealSubject' class
44 | ///
45 | class Math : MarshalByRefObject, IMath
46 | {
47 | public double Add(double x, double y) { return x + y; }
48 | public double Sub(double x, double y) { return x - y; }
49 | public double Mul(double x, double y) { return x * y; }
50 | public double Div(double x, double y) { return x / y; }
51 | }
52 |
53 | ///
54 | /// The remote 'Proxy Object' class
55 | ///
56 | class MathProxy : IMath
57 | {
58 | Math math;
59 |
60 | // Constructor
61 | public MathProxy()
62 | {
63 | // Create Math instance in a different AppDomain
64 | var ad = AppDomain.CreateDomain("MathDomain", null, null);
65 |
66 | var o = ad.CreateInstance(
67 | "DoFactory.GangOfFour.Proxy.NETOptimized",
68 | "DoFactory.GangOfFour.Proxy.NETOptimized.Math");
69 | math = (Math)o.Unwrap();
70 | }
71 |
72 | public double Add(double x, double y)
73 | {
74 | return math.Add(x, y);
75 | }
76 |
77 | public double Sub(double x, double y)
78 | {
79 | return math.Sub(x, y);
80 | }
81 |
82 | public double Mul(double x, double y)
83 | {
84 | return math.Mul(x, y);
85 | }
86 |
87 | public double Div(double x, double y)
88 | {
89 | return math.Div(x, y);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.Proxy.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.Proxy.NETOptimized/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.State.RealWorld/App.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.State.RealWorld/App.ico
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.State.RealWorld/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/DoFactory.GangOfFour.State.RealWorld/AssemblyInfo.cs
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.State.RealWorld/DoFactory.GangOfFour.State.RealWorld.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local
5 | 9.0.21022
6 | 2.0
7 | {FDCCE772-71F3-4343-8537-30FBE33B0503}
8 | Debug
9 | AnyCPU
10 | App.ico
11 |
12 |
13 | DoFactory.GangOfFour.State.RealWorld
14 |
15 |
16 | JScript
17 | Grid
18 | IE50
19 | false
20 | Exe
21 | DoFactory.GangOfFour.State.RealWorld
22 | OnBuildSuccess
23 |
24 |
25 |
26 |
27 |
28 |
29 | 3.5
30 | v4.5
31 | publish\
32 | true
33 | Disk
34 | false
35 | Foreground
36 | 7
37 | Days
38 | false
39 | false
40 | true
41 | 0
42 | 1.0.0.%2a
43 | false
44 | false
45 | true
46 |
47 |
48 |
49 | bin\Debug\
50 | false
51 | 285212672
52 | false
53 |
54 |
55 | DEBUG;TRACE
56 |
57 |
58 | true
59 | 4096
60 | false
61 |
62 |
63 | false
64 | false
65 | false
66 | false
67 | 4
68 | full
69 | prompt
70 | AllRules.ruleset
71 | false
72 |
73 |
74 | bin\Release\
75 | false
76 | 285212672
77 | false
78 |
79 |
80 | TRACE
81 |
82 |
83 | false
84 | 4096
85 | false
86 |
87 |
88 | true
89 | false
90 | false
91 | false
92 | 4
93 | none
94 | prompt
95 | AllRules.ruleset
96 | false
97 |
98 |
99 |
100 | System
101 |
102 |
103 | 3.5
104 |
105 |
106 | System.Data
107 |
108 |
109 | System.XML
110 |
111 |
112 |
113 |
114 |
115 | Code
116 |
117 |
118 | Code
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 | False
138 | Windows Installer 3.1
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.State.RealWorld/DoFactory.GangOfFour.State.RealWorld.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 7.10.3077
5 | Debug
6 | AnyCPU
7 |
8 |
9 |
10 |
11 |
12 |
13 | 0
14 | ProjectFiles
15 | 0
16 |
17 |
18 |
19 |
20 |
21 |
22 | en-US
23 | false
24 |
25 |
26 | false
27 | false
28 | false
29 | false
30 | false
31 |
32 |
33 | Project
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 |
46 |
47 | false
48 | false
49 | false
50 | false
51 | false
52 |
53 |
54 | Project
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | false
66 |
67 |
--------------------------------------------------------------------------------
/DoFactory.GangOfFour.State.RealWorld/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Gang of Four Design Patterns 4.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/Gang of Four Design Patterns 4.5.pdf
--------------------------------------------------------------------------------
/Getting Started 4.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/Getting Started 4.5.pdf
--------------------------------------------------------------------------------
/Head First Design Patterns 4.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/Head First Design Patterns 4.5.pdf
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | ================================================
2 | LICENSE AND WARRANTY
3 | ------------------------------------------------
4 | This statement pertains to the Design Pattern
5 | Framework (the 'product').
6 |
7 | You are free to install the product on as many
8 | machines as necessary (home, work, etc.) as
9 | long as the number of users does not exceed the
10 | license.
11 |
12 | If this is a single-user license the product can
13 | only be used by a single user. If you purchased
14 | a 16-user license then the product can be
15 | used by up to 16 developers. Site licenses
16 | are restricted to a single facility at a given
17 | physical address
18 |
19 | You are free to use the source code in your own
20 | business applications. However, you are not
21 | allowed to use the source code to develop
22 | framework-type products and/or code-generators,
23 | either commercial or open-source
24 |
25 | THIS CODE AND INFORMATION IS PROVIDED "AS IS"
26 | WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
27 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
29 | FITNESS FOR A PARTICULAR PURPOSE.
30 |
31 | ------------------------------------------------
32 | Copyright (C), Data & Object Factory, LLC
33 | All rights reserved. www.dofactory.com
34 |
--------------------------------------------------------------------------------
/Patterns In Action 4.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/Patterns In Action 4.5.pdf
--------------------------------------------------------------------------------
/README.TXT:
--------------------------------------------------------------------------------
1 | To get started, please read the 'Getting Started 4.5.pdf' document first.
2 | =================
3 | www.downloadly.ir
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PRO .NET Design Pattern Framework 4.5
2 |
3 |
4 | Design patterns are solutions to software design problems you find again and again in real-world application development. Patterns are about reusable designs and interactions of objects.
5 |
6 | The 23 Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural, and Behavioral (for a complete list see below).
7 |
8 | To give you a head start, the C# source code for each pattern is provided in 2 forms: structural and real-world. Structural code uses type names as defined in the pattern definition and UML diagrams. Real-world code provides real-world programming situations where you may use these patterns.
9 |
10 | A third form, .NET optimized, demonstrates design patterns that fully exploit built-in .NET 4.5 features, such as, generics, attributes, delegates, reflection, and more. These and much more are available in our .NET Design Pattern Framework 4.5. You can see the Singleton page for a .NET 4.5 Optimized example.
11 |
--------------------------------------------------------------------------------
/Spark 4.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/Spark 4.5.pdf
--------------------------------------------------------------------------------
/db1.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rpg101a/Design-Patterns/fa14652b569b00557833a4ff2bcd142f83e96d2d/db1.mdb
--------------------------------------------------------------------------------