Commiting the Design Pattern Project
Showing
100 changed files
with
2516 additions
and
0 deletions
Too many changes to show.
To preserve performance only 100 of 100+ files are displayed.
AbstractFactory/.gitkeep
deleted
100644 → 0
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Abstract_Factory</RootNamespace> | ||
12 | + <AssemblyName>Abstract Factory</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
50 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
51 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
52 | + <Target Name="BeforeBuild"> | ||
53 | + </Target> | ||
54 | + <Target Name="AfterBuild"> | ||
55 | + </Target> | ||
56 | + --> | ||
57 | +</Project> |
Design Patterns/Abstract Factory/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +//Provide an interface for creating families of related or dependent objects without specifying their concrete classes. | ||
7 | + | ||
8 | +namespace Abstract_Factory | ||
9 | +{ | ||
10 | + /// <summary> | ||
11 | + | ||
12 | + /// MainApp startup class for Structural | ||
13 | + | ||
14 | + /// Abstract Factory Design Pattern. | ||
15 | + | ||
16 | + /// </summary> | ||
17 | + | ||
18 | + class MainApp | ||
19 | + { | ||
20 | + /// <summary> | ||
21 | + | ||
22 | + /// Entry point into console application. | ||
23 | + | ||
24 | + /// </summary> | ||
25 | + | ||
26 | + public static void Main() | ||
27 | + { | ||
28 | + // Abstract factory #1 | ||
29 | + | ||
30 | + AbstractFactory factory1 = new ConcreteFactory1(); | ||
31 | + Client client1 = new Client(factory1); | ||
32 | + client1.Run(); | ||
33 | + | ||
34 | + // Abstract factory #2 | ||
35 | + | ||
36 | + AbstractFactory factory2 = new ConcreteFactory2(); | ||
37 | + Client client2 = new Client(factory2); | ||
38 | + client2.Run(); | ||
39 | + | ||
40 | + // Wait for user input | ||
41 | + | ||
42 | + Console.ReadKey(); | ||
43 | + } | ||
44 | + } | ||
45 | + | ||
46 | + /// <summary> | ||
47 | + | ||
48 | + /// The 'AbstractFactory' abstract class | ||
49 | + | ||
50 | + /// </summary> | ||
51 | + | ||
52 | + abstract class AbstractFactory | ||
53 | + { | ||
54 | + public abstract AbstractProductA CreateProductA(); | ||
55 | + public abstract AbstractProductB CreateProductB(); | ||
56 | + } | ||
57 | + | ||
58 | + | ||
59 | + /// <summary> | ||
60 | + | ||
61 | + /// The 'ConcreteFactory1' class | ||
62 | + | ||
63 | + /// </summary> | ||
64 | + | ||
65 | + class ConcreteFactory1 : AbstractFactory | ||
66 | + { | ||
67 | + public override AbstractProductA CreateProductA() | ||
68 | + { | ||
69 | + return new ProductA1(); | ||
70 | + } | ||
71 | + public override AbstractProductB CreateProductB() | ||
72 | + { | ||
73 | + return new ProductB1(); | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + /// <summary> | ||
78 | + | ||
79 | + /// The 'ConcreteFactory2' class | ||
80 | + | ||
81 | + /// </summary> | ||
82 | + | ||
83 | + class ConcreteFactory2 : AbstractFactory | ||
84 | + { | ||
85 | + public override AbstractProductA CreateProductA() | ||
86 | + { | ||
87 | + return new ProductA2(); | ||
88 | + } | ||
89 | + public override AbstractProductB CreateProductB() | ||
90 | + { | ||
91 | + return new ProductB2(); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /// <summary> | ||
96 | + | ||
97 | + /// The 'AbstractProductA' abstract class | ||
98 | + | ||
99 | + /// </summary> | ||
100 | + | ||
101 | + abstract class AbstractProductA | ||
102 | + { | ||
103 | + } | ||
104 | + | ||
105 | + /// <summary> | ||
106 | + | ||
107 | + /// The 'AbstractProductB' abstract class | ||
108 | + | ||
109 | + /// </summary> | ||
110 | + | ||
111 | + abstract class AbstractProductB | ||
112 | + { | ||
113 | + public abstract void Interact(AbstractProductA a); | ||
114 | + } | ||
115 | + | ||
116 | + | ||
117 | + /// <summary> | ||
118 | + | ||
119 | + /// The 'ProductA1' class | ||
120 | + | ||
121 | + /// </summary> | ||
122 | + | ||
123 | + class ProductA1 : AbstractProductA | ||
124 | + { | ||
125 | + } | ||
126 | + | ||
127 | + /// <summary> | ||
128 | + | ||
129 | + /// The 'ProductB1' class | ||
130 | + | ||
131 | + /// </summary> | ||
132 | + | ||
133 | + class ProductB1 : AbstractProductB | ||
134 | + { | ||
135 | + public override void Interact(AbstractProductA a) | ||
136 | + { | ||
137 | + Console.WriteLine(this.GetType().Name + | ||
138 | + " interacts with " + a.GetType().Name); | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + /// <summary> | ||
143 | + | ||
144 | + /// The 'ProductA2' class | ||
145 | + | ||
146 | + /// </summary> | ||
147 | + | ||
148 | + class ProductA2 : AbstractProductA | ||
149 | + { | ||
150 | + } | ||
151 | + | ||
152 | + /// <summary> | ||
153 | + | ||
154 | + /// The 'ProductB2' class | ||
155 | + | ||
156 | + /// </summary> | ||
157 | + | ||
158 | + class ProductB2 : AbstractProductB | ||
159 | + { | ||
160 | + public override void Interact(AbstractProductA a) | ||
161 | + { | ||
162 | + Console.WriteLine(this.GetType().Name + | ||
163 | + " interacts with " + a.GetType().Name); | ||
164 | + } | ||
165 | + } | ||
166 | + | ||
167 | + /// <summary> | ||
168 | + | ||
169 | + /// The 'Client' class. Interaction environment for the products. | ||
170 | + | ||
171 | + /// </summary> | ||
172 | + | ||
173 | + class Client | ||
174 | + { | ||
175 | + private AbstractProductA _abstractProductA; | ||
176 | + private AbstractProductB _abstractProductB; | ||
177 | + | ||
178 | + // Constructor | ||
179 | + | ||
180 | + public Client(AbstractFactory factory) | ||
181 | + { | ||
182 | + _abstractProductB = factory.CreateProductB(); | ||
183 | + _abstractProductA = factory.CreateProductA(); | ||
184 | + } | ||
185 | + | ||
186 | + public void Run() | ||
187 | + { | ||
188 | + _abstractProductB.Interact(_abstractProductA); | ||
189 | + } | ||
190 | + } | ||
191 | +} |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Abstract Factory")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Abstract Factory")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("d0da81c5-80b1-4ed5-80ea-58dc3dc4d9d4")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
3 | + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
4 | + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
5 | + <security> | ||
6 | + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
7 | + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
8 | + </requestedPrivileges> | ||
9 | + </security> | ||
10 | + </trustInfo> | ||
11 | +</assembly> |
Design Patterns/Abstract Factory/obj/x86/Debug/Abstract Factory.csproj.FileListAbsolute.txt
0 → 100644
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\bin\Debug\Abstract Factory.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\bin\Debug\Abstract Factory.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\obj\x86\Debug\Abstract Factory.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\obj\x86\Debug\Abstract Factory.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Abstract Factory/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
0 → 100644
No preview for this file type
Design Patterns/Adapter/Adapter.GIF
0 → 100644
8.34 KB
Design Patterns/Adapter/Adapter.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{0267B2D7-39C6-4C11-90FF-540527EF457A}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Adapter</RootNamespace> | ||
12 | + <AssemblyName>Adapter</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <ItemGroup> | ||
50 | + <Content Include="Adapter.GIF" /> | ||
51 | + </ItemGroup> | ||
52 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
53 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
54 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
55 | + <Target Name="BeforeBuild"> | ||
56 | + </Target> | ||
57 | + <Target Name="AfterBuild"> | ||
58 | + </Target> | ||
59 | + --> | ||
60 | +</Project> |
Design Patterns/Adapter/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Adapter | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Adapter Design Pattern. | ||
13 | + //Convert the interface of a class into another interface clients expect. | ||
14 | + //Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. | ||
15 | + /// </summary> | ||
16 | + | ||
17 | + class MainApp | ||
18 | + { | ||
19 | + /// <summary> | ||
20 | + | ||
21 | + /// Entry point into console application. | ||
22 | + | ||
23 | + /// </summary> | ||
24 | + | ||
25 | + static void Main() | ||
26 | + { | ||
27 | + // Create adapter and place a request | ||
28 | + | ||
29 | + Target target = new Adapter(); | ||
30 | + target.Request(); | ||
31 | + | ||
32 | + // Wait for user | ||
33 | + | ||
34 | + Console.ReadKey(); | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + /// <summary> | ||
39 | + | ||
40 | + /// The 'Target' class | ||
41 | + | ||
42 | + /// </summary> | ||
43 | + | ||
44 | + class Target | ||
45 | + { | ||
46 | + public virtual void Request() | ||
47 | + { | ||
48 | + Console.WriteLine("Called Target Request()"); | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + /// <summary> | ||
53 | + | ||
54 | + /// The 'Adapter' class | ||
55 | + | ||
56 | + /// </summary> | ||
57 | + | ||
58 | + class Adapter : Target | ||
59 | + { | ||
60 | + private Adaptee _adaptee = new Adaptee(); | ||
61 | + | ||
62 | + public override void Request() | ||
63 | + { | ||
64 | + // Possibly do some other work | ||
65 | + | ||
66 | + // and then call SpecificRequest | ||
67 | + | ||
68 | + _adaptee.SpecificRequest(); | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
72 | + /// <summary> | ||
73 | + | ||
74 | + /// The 'Adaptee' class | ||
75 | + | ||
76 | + /// </summary> | ||
77 | + | ||
78 | + class Adaptee | ||
79 | + { | ||
80 | + public void SpecificRequest() | ||
81 | + { | ||
82 | + Console.WriteLine("Called SpecificRequest()"); | ||
83 | + } | ||
84 | + } | ||
85 | +} |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Adapter")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Adapter")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("1842066e-4be3-412f-8b8d-f2a4fb726f79")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\bin\Debug\Adapter.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\bin\Debug\Adapter.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\obj\x86\Debug\Adapter.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\obj\x86\Debug\Adapter.pdb |
No preview for this file type
No preview for this file type
No preview for this file type
Design Patterns/Bridge/Bridge.GIF
0 → 100644
12.2 KB
Design Patterns/Bridge/Bridge.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{B5700B60-C82F-4765-9695-CE0B43BCA5D7}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Bridge</RootNamespace> | ||
12 | + <AssemblyName>Bridge</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <ItemGroup> | ||
50 | + <Content Include="Bridge.GIF" /> | ||
51 | + </ItemGroup> | ||
52 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
53 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
54 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
55 | + <Target Name="BeforeBuild"> | ||
56 | + </Target> | ||
57 | + <Target Name="AfterBuild"> | ||
58 | + </Target> | ||
59 | + --> | ||
60 | +</Project> |
Design Patterns/Bridge/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Bridge | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Bridge Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + //Decouple an abstraction from its implementation so that the two can vary independently. | ||
16 | + class MainApp | ||
17 | + { | ||
18 | + /// <summary> | ||
19 | + | ||
20 | + /// Entry point into console application. | ||
21 | + | ||
22 | + /// </summary> | ||
23 | + | ||
24 | + static void Main() | ||
25 | + { | ||
26 | + Abstraction ab = new RefinedAbstraction(); | ||
27 | + | ||
28 | + // Set implementation and call | ||
29 | + | ||
30 | + ab.Implementor = new ConcreteImplementorA(); | ||
31 | + ab.Operation(); | ||
32 | + | ||
33 | + // Change implemention and call | ||
34 | + | ||
35 | + ab.Implementor = new ConcreteImplementorB(); | ||
36 | + ab.Operation(); | ||
37 | + | ||
38 | + // Wait for user | ||
39 | + | ||
40 | + Console.ReadKey(); | ||
41 | + } | ||
42 | + } | ||
43 | + | ||
44 | + /// <summary> | ||
45 | + | ||
46 | + /// The 'Abstraction' class | ||
47 | + | ||
48 | + /// </summary> | ||
49 | + | ||
50 | + class Abstraction | ||
51 | + { | ||
52 | + protected Implementor implementor; | ||
53 | + | ||
54 | + // Property | ||
55 | + | ||
56 | + public Implementor Implementor | ||
57 | + { | ||
58 | + set { implementor = value; } | ||
59 | + } | ||
60 | + | ||
61 | + public virtual void Operation() | ||
62 | + { | ||
63 | + implementor.Operation(); | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + /// <summary> | ||
68 | + | ||
69 | + /// The 'Implementor' abstract class | ||
70 | + | ||
71 | + /// </summary> | ||
72 | + | ||
73 | + abstract class Implementor | ||
74 | + { | ||
75 | + public abstract void Operation(); | ||
76 | + } | ||
77 | + | ||
78 | + /// <summary> | ||
79 | + | ||
80 | + /// The 'RefinedAbstraction' class | ||
81 | + | ||
82 | + /// </summary> | ||
83 | + | ||
84 | + class RefinedAbstraction : Abstraction | ||
85 | + { | ||
86 | + public override void Operation() | ||
87 | + { | ||
88 | + implementor.Operation(); | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + /// <summary> | ||
93 | + | ||
94 | + /// The 'ConcreteImplementorA' class | ||
95 | + | ||
96 | + /// </summary> | ||
97 | + | ||
98 | + class ConcreteImplementorA : Implementor | ||
99 | + { | ||
100 | + public override void Operation() | ||
101 | + { | ||
102 | + Console.WriteLine("ConcreteImplementorA Operation"); | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + /// <summary> | ||
107 | + | ||
108 | + /// The 'ConcreteImplementorB' class | ||
109 | + | ||
110 | + /// </summary> | ||
111 | + | ||
112 | + class ConcreteImplementorB : Implementor | ||
113 | + { | ||
114 | + public override void Operation() | ||
115 | + { | ||
116 | + Console.WriteLine("ConcreteImplementorB Operation"); | ||
117 | + } | ||
118 | + } | ||
119 | +} |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Bridge")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Bridge")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("ad735d41-ed7a-4ef9-9592-60256f4b3634")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
Design Patterns/Bridge/bin/Debug/Bridge.exe
0 → 100644
No preview for this file type
Design Patterns/Bridge/bin/Debug/Bridge.pdb
0 → 100644
No preview for this file type
No preview for this file type
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
3 | + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
4 | + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
5 | + <security> | ||
6 | + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
7 | + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
8 | + </requestedPrivileges> | ||
9 | + </security> | ||
10 | + </trustInfo> | ||
11 | +</assembly> |
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\bin\Debug\Bridge.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\bin\Debug\Bridge.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\obj\x86\Debug\Bridge.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\obj\x86\Debug\Bridge.pdb |
No preview for this file type
No preview for this file type
No preview for this file type
Design Patterns/Builder/Builder.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{50C2CC17-B3BC-4DB3-8901-24D18B757C23}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Builder</RootNamespace> | ||
12 | + <AssemblyName>Builder</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
50 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
51 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
52 | + <Target Name="BeforeBuild"> | ||
53 | + </Target> | ||
54 | + <Target Name="AfterBuild"> | ||
55 | + </Target> | ||
56 | + --> | ||
57 | +</Project> |
Design Patterns/Builder/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Builder | ||
7 | +{ | ||
8 | + using System; | ||
9 | + using System.Collections.Generic; | ||
10 | + | ||
11 | + namespace DoFactory.GangOfFour.Builder.Structural | ||
12 | + { | ||
13 | + /// <summary> | ||
14 | + | ||
15 | + /// MainApp startup class for Structural | ||
16 | + | ||
17 | + /// Builder Design Pattern. | ||
18 | + | ||
19 | + /// </summary> | ||
20 | + | ||
21 | + public class MainApp | ||
22 | + { | ||
23 | + /// <summary> | ||
24 | + | ||
25 | + /// Entry point into console application. | ||
26 | + | ||
27 | + /// </summary> | ||
28 | + | ||
29 | + public static void Main() | ||
30 | + { | ||
31 | + // Create director and builders | ||
32 | + | ||
33 | + Director director = new Director(); | ||
34 | + | ||
35 | + Builder b1 = new ConcreteBuilder1(); | ||
36 | + Builder b2 = new ConcreteBuilder2(); | ||
37 | + | ||
38 | + // Construct two products | ||
39 | + | ||
40 | + director.Construct(b1); | ||
41 | + Product p1 = b1.GetResult(); | ||
42 | + p1.Show(); | ||
43 | + | ||
44 | + director.Construct(b2); | ||
45 | + Product p2 = b2.GetResult(); | ||
46 | + p2.Show(); | ||
47 | + | ||
48 | + // Wait for user | ||
49 | + | ||
50 | + Console.ReadKey(); | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + /// <summary> | ||
55 | + | ||
56 | + /// The 'Director' class | ||
57 | + | ||
58 | + /// </summary> | ||
59 | + | ||
60 | + class Director | ||
61 | + { | ||
62 | + // Builder uses a complex series of steps | ||
63 | + | ||
64 | + public void Construct(Builder builder) | ||
65 | + { | ||
66 | + builder.BuildPartA(); | ||
67 | + builder.BuildPartB(); | ||
68 | + } | ||
69 | + } | ||
70 | + | ||
71 | + /// <summary> | ||
72 | + | ||
73 | + /// The 'Builder' abstract class | ||
74 | + | ||
75 | + /// </summary> | ||
76 | + | ||
77 | + abstract class Builder | ||
78 | + { | ||
79 | + public abstract void BuildPartA(); | ||
80 | + public abstract void BuildPartB(); | ||
81 | + public abstract Product GetResult(); | ||
82 | + } | ||
83 | + | ||
84 | + /// <summary> | ||
85 | + | ||
86 | + /// The 'ConcreteBuilder1' class | ||
87 | + | ||
88 | + /// </summary> | ||
89 | + | ||
90 | + class ConcreteBuilder1 : Builder | ||
91 | + { | ||
92 | + private Product _product = new Product(); | ||
93 | + | ||
94 | + public override void BuildPartA() | ||
95 | + { | ||
96 | + _product.Add("PartA"); | ||
97 | + } | ||
98 | + | ||
99 | + public override void BuildPartB() | ||
100 | + { | ||
101 | + _product.Add("PartB"); | ||
102 | + } | ||
103 | + | ||
104 | + public override Product GetResult() | ||
105 | + { | ||
106 | + return _product; | ||
107 | + } | ||
108 | + } | ||
109 | + | ||
110 | + /// <summary> | ||
111 | + | ||
112 | + /// The 'ConcreteBuilder2' class | ||
113 | + | ||
114 | + /// </summary> | ||
115 | + | ||
116 | + class ConcreteBuilder2 : Builder | ||
117 | + { | ||
118 | + private Product _product = new Product(); | ||
119 | + | ||
120 | + public override void BuildPartA() | ||
121 | + { | ||
122 | + _product.Add("PartX"); | ||
123 | + } | ||
124 | + | ||
125 | + public override void BuildPartB() | ||
126 | + { | ||
127 | + _product.Add("PartY"); | ||
128 | + } | ||
129 | + | ||
130 | + public override Product GetResult() | ||
131 | + { | ||
132 | + return _product; | ||
133 | + } | ||
134 | + } | ||
135 | + | ||
136 | + /// <summary> | ||
137 | + | ||
138 | + /// The 'Product' class | ||
139 | + | ||
140 | + /// </summary> | ||
141 | + | ||
142 | + class Product | ||
143 | + { | ||
144 | + private List<string> _parts = new List<string>(); | ||
145 | + | ||
146 | + public void Add(string part) | ||
147 | + { | ||
148 | + _parts.Add(part); | ||
149 | + } | ||
150 | + | ||
151 | + public void Show() | ||
152 | + { | ||
153 | + Console.WriteLine("\nProduct Parts -------"); | ||
154 | + foreach (string part in _parts) | ||
155 | + Console.WriteLine(part); | ||
156 | + } | ||
157 | + } | ||
158 | + } | ||
159 | +} |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Builder")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Builder")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("eccc81ee-aafa-4853-b7cd-8fcdb3909ba0")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
3 | + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
4 | + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
5 | + <security> | ||
6 | + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
7 | + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
8 | + </requestedPrivileges> | ||
9 | + </security> | ||
10 | + </trustInfo> | ||
11 | +</assembly> |
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\bin\Debug\Builder.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\bin\Debug\Builder.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\obj\x86\Debug\Builder.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\obj\x86\Debug\Builder.pdb |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{1FDCC993-010F-4E94-BA56-EF52EB9D8397}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Chain_of_Responsibility</RootNamespace> | ||
12 | + <AssemblyName>Chain of Responsibility</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <ItemGroup> | ||
50 | + <Content Include="Chain_Of_Responsibility.PNG" /> | ||
51 | + </ItemGroup> | ||
52 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
53 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
54 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
55 | + <Target Name="BeforeBuild"> | ||
56 | + </Target> | ||
57 | + <Target Name="AfterBuild"> | ||
58 | + </Target> | ||
59 | + --> | ||
60 | +</Project> |
10.8 KB
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Chain_of_Responsibility | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Chain of Responsibility Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + /// | ||
16 | + | ||
17 | + //Definition | ||
18 | + //Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. | ||
19 | + //Chain the receiving objects and pass the request along the chain until an object handles it. | ||
20 | + | ||
21 | + class MainApp | ||
22 | + { | ||
23 | + /// <summary> | ||
24 | + | ||
25 | + /// Entry point into console application. | ||
26 | + | ||
27 | + /// </summary> | ||
28 | + | ||
29 | + static void Main() | ||
30 | + { | ||
31 | + // Setup Chain of Responsibility | ||
32 | + | ||
33 | + Handler h1 = new ConcreteHandler1(); | ||
34 | + Handler h2 = new ConcreteHandler2(); | ||
35 | + Handler h3 = new ConcreteHandler3(); | ||
36 | + h1.SetSuccessor(h2); | ||
37 | + h2.SetSuccessor(h3); | ||
38 | + | ||
39 | + // Generate and process request | ||
40 | + | ||
41 | + int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 }; | ||
42 | + | ||
43 | + foreach (int request in requests) | ||
44 | + { | ||
45 | + h1.HandleRequest(request); | ||
46 | + } | ||
47 | + | ||
48 | + // Wait for user | ||
49 | + | ||
50 | + Console.ReadKey(); | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + /// <summary> | ||
55 | + | ||
56 | + /// The 'Handler' abstract class | ||
57 | + | ||
58 | + /// </summary> | ||
59 | + | ||
60 | + abstract class Handler | ||
61 | + { | ||
62 | + protected Handler successor; | ||
63 | + | ||
64 | + public void SetSuccessor(Handler successor) | ||
65 | + { | ||
66 | + this.successor = successor; | ||
67 | + } | ||
68 | + | ||
69 | + public abstract void HandleRequest(int request); | ||
70 | + } | ||
71 | + | ||
72 | + /// <summary> | ||
73 | + | ||
74 | + /// The 'ConcreteHandler1' class | ||
75 | + | ||
76 | + /// </summary> | ||
77 | + | ||
78 | + class ConcreteHandler1 : Handler | ||
79 | + { | ||
80 | + public override void HandleRequest(int request) | ||
81 | + { | ||
82 | + if (request >= 0 && request < 10) | ||
83 | + { | ||
84 | + Console.WriteLine("{0} handled request {1}", | ||
85 | + this.GetType().Name, request); | ||
86 | + } | ||
87 | + else if (successor != null) | ||
88 | + { | ||
89 | + successor.HandleRequest(request); | ||
90 | + } | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + /// <summary> | ||
95 | + | ||
96 | + /// The 'ConcreteHandler2' class | ||
97 | + | ||
98 | + /// </summary> | ||
99 | + | ||
100 | + class ConcreteHandler2 : Handler | ||
101 | + { | ||
102 | + public override void HandleRequest(int request) | ||
103 | + { | ||
104 | + if (request >= 10 && request < 20) | ||
105 | + { | ||
106 | + Console.WriteLine("{0} handled request {1}", | ||
107 | + this.GetType().Name, request); | ||
108 | + } | ||
109 | + else if (successor != null) | ||
110 | + { | ||
111 | + successor.HandleRequest(request); | ||
112 | + } | ||
113 | + } | ||
114 | + } | ||
115 | + | ||
116 | + /// <summary> | ||
117 | + | ||
118 | + /// The 'ConcreteHandler3' class | ||
119 | + | ||
120 | + /// </summary> | ||
121 | + | ||
122 | + class ConcreteHandler3 : Handler | ||
123 | + { | ||
124 | + public override void HandleRequest(int request) | ||
125 | + { | ||
126 | + if (request >= 20 && request < 30) | ||
127 | + { | ||
128 | + Console.WriteLine("{0} handled request {1}", | ||
129 | + this.GetType().Name, request); | ||
130 | + } | ||
131 | + else if (successor != null) | ||
132 | + { | ||
133 | + successor.HandleRequest(request); | ||
134 | + } | ||
135 | + } | ||
136 | + } | ||
137 | +} | ||
138 | + |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Chain of Responsibility")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Chain of Responsibility")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("72ec58d3-0328-4bcc-b410-dc6a00ff8730")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
No preview for this file type
Design Patterns/Chain of Responsibility/bin/Debug/Chain of Responsibility.vshost.exe.manifest
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
3 | + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
4 | + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
5 | + <security> | ||
6 | + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
7 | + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
8 | + </requestedPrivileges> | ||
9 | + </security> | ||
10 | + </trustInfo> | ||
11 | +</assembly> |
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\bin\Debug\Chain of Responsibility.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\bin\Debug\Chain of Responsibility.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\obj\x86\Debug\Chain of Responsibility.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\obj\x86\Debug\Chain of Responsibility.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Chain of Responsibility/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
0 → 100644
No preview for this file type
Design Patterns/Command/Command.GIF
0 → 100644
9.28 KB
Design Patterns/Command/Command.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Command</RootNamespace> | ||
12 | + <AssemblyName>Command</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <ItemGroup> | ||
50 | + <Content Include="Command.GIF" /> | ||
51 | + </ItemGroup> | ||
52 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
53 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
54 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
55 | + <Target Name="BeforeBuild"> | ||
56 | + </Target> | ||
57 | + <Target Name="AfterBuild"> | ||
58 | + </Target> | ||
59 | + --> | ||
60 | +</Project> |
Design Patterns/Command/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Command | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Command Design Pattern. | ||
13 | + /// Encapsulate a request as an object, thereby letting you parameterize clients with different requests, | ||
14 | + /// queue or log requests, and support undoable operations. | ||
15 | + | ||
16 | + /// </summary> | ||
17 | + | ||
18 | + class MainApp | ||
19 | + { | ||
20 | + /// <summary> | ||
21 | + | ||
22 | + /// Entry point into console application. | ||
23 | + | ||
24 | + /// </summary> | ||
25 | + | ||
26 | + static void Main() | ||
27 | + { | ||
28 | + // Create receiver, command, and invoker | ||
29 | + | ||
30 | + Receiver receiver = new Receiver(); | ||
31 | + Command command = new ConcreteCommand(receiver); | ||
32 | + Invoker invoker = new Invoker(); | ||
33 | + | ||
34 | + // Set and execute command | ||
35 | + | ||
36 | + invoker.SetCommand(command); | ||
37 | + invoker.ExecuteCommand(); | ||
38 | + | ||
39 | + // Wait for user | ||
40 | + | ||
41 | + Console.ReadKey(); | ||
42 | + } | ||
43 | + } | ||
44 | + | ||
45 | + /// <summary> | ||
46 | + | ||
47 | + /// The 'Command' abstract class | ||
48 | + | ||
49 | + /// </summary> | ||
50 | + | ||
51 | + abstract class Command | ||
52 | + { | ||
53 | + protected Receiver receiver; | ||
54 | + | ||
55 | + // Constructor | ||
56 | + | ||
57 | + public Command(Receiver receiver) | ||
58 | + { | ||
59 | + this.receiver = receiver; | ||
60 | + } | ||
61 | + | ||
62 | + public abstract void Execute(); | ||
63 | + } | ||
64 | + | ||
65 | + /// <summary> | ||
66 | + | ||
67 | + /// The 'ConcreteCommand' class | ||
68 | + | ||
69 | + /// </summary> | ||
70 | + | ||
71 | + class ConcreteCommand : Command | ||
72 | + { | ||
73 | + // Constructor | ||
74 | + | ||
75 | + public ConcreteCommand(Receiver receiver) : | ||
76 | + base(receiver) | ||
77 | + { | ||
78 | + } | ||
79 | + | ||
80 | + public override void Execute() | ||
81 | + { | ||
82 | + receiver.Action(); | ||
83 | + } | ||
84 | + } | ||
85 | + | ||
86 | + /// <summary> | ||
87 | + | ||
88 | + /// The 'Receiver' class | ||
89 | + | ||
90 | + /// </summary> | ||
91 | + | ||
92 | + class Receiver | ||
93 | + { | ||
94 | + public void Action() | ||
95 | + { | ||
96 | + Console.WriteLine("Called Receiver.Action()"); | ||
97 | + } | ||
98 | + } | ||
99 | + | ||
100 | + /// <summary> | ||
101 | + | ||
102 | + /// The 'Invoker' class | ||
103 | + | ||
104 | + /// </summary> | ||
105 | + | ||
106 | + class Invoker | ||
107 | + { | ||
108 | + private Command _command; | ||
109 | + | ||
110 | + public void SetCommand(Command command) | ||
111 | + { | ||
112 | + this._command = command; | ||
113 | + } | ||
114 | + | ||
115 | + public void ExecuteCommand() | ||
116 | + { | ||
117 | + _command.Execute(); | ||
118 | + } | ||
119 | + } | ||
120 | +} |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Command")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Command")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("f3ceae8f-5101-46b3-9a96-2446e271892f")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\bin\Debug\Command.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\bin\Debug\Command.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\obj\x86\Debug\Command.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\obj\x86\Debug\Command.pdb |
No preview for this file type
No preview for this file type
No preview for this file type
Design Patterns/Composite/Composite.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Composite</RootNamespace> | ||
12 | + <AssemblyName>Composite</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
50 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
51 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
52 | + <Target Name="BeforeBuild"> | ||
53 | + </Target> | ||
54 | + <Target Name="AfterBuild"> | ||
55 | + </Target> | ||
56 | + --> | ||
57 | +</Project> |
Design Patterns/Composite/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Composite | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Composite Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + | ||
16 | + class MainApp | ||
17 | + { | ||
18 | + /// <summary> | ||
19 | + | ||
20 | + /// Entry point into console application. | ||
21 | + | ||
22 | + /// </summary> | ||
23 | + | ||
24 | + static void Main() | ||
25 | + { | ||
26 | + // Create a tree structure | ||
27 | + | ||
28 | + Composite root = new Composite("root"); | ||
29 | + root.Add(new Leaf("Leaf A")); | ||
30 | + root.Add(new Leaf("Leaf B")); | ||
31 | + | ||
32 | + Composite comp = new Composite("Composite X"); | ||
33 | + comp.Add(new Leaf("Leaf XA")); | ||
34 | + comp.Add(new Leaf("Leaf XB")); | ||
35 | + | ||
36 | + root.Add(comp); | ||
37 | + root.Add(new Leaf("Leaf C")); | ||
38 | + | ||
39 | + // Add and remove a leaf | ||
40 | + | ||
41 | + Leaf leaf = new Leaf("Leaf D"); | ||
42 | + root.Add(leaf); | ||
43 | + root.Remove(leaf); | ||
44 | + | ||
45 | + // Recursively display tree | ||
46 | + | ||
47 | + root.Display(1); | ||
48 | + | ||
49 | + // Wait for user | ||
50 | + | ||
51 | + Console.ReadKey(); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + /// <summary> | ||
56 | + | ||
57 | + /// The 'Component' abstract class | ||
58 | + | ||
59 | + /// </summary> | ||
60 | + | ||
61 | + abstract class Component | ||
62 | + { | ||
63 | + protected string name; | ||
64 | + | ||
65 | + // Constructor | ||
66 | + | ||
67 | + public Component(string name) | ||
68 | + { | ||
69 | + this.name = name; | ||
70 | + } | ||
71 | + | ||
72 | + public abstract void Add(Component c); | ||
73 | + public abstract void Remove(Component c); | ||
74 | + public abstract void Display(int depth); | ||
75 | + } | ||
76 | + | ||
77 | + /// <summary> | ||
78 | + | ||
79 | + /// The 'Composite' class | ||
80 | + | ||
81 | + /// </summary> | ||
82 | + | ||
83 | + class Composite : Component | ||
84 | + { | ||
85 | + private List<Component> _children = new List<Component>(); | ||
86 | + | ||
87 | + // Constructor | ||
88 | + | ||
89 | + public Composite(string name) | ||
90 | + : base(name) | ||
91 | + { | ||
92 | + } | ||
93 | + | ||
94 | + public override void Add(Component component) | ||
95 | + { | ||
96 | + _children.Add(component); | ||
97 | + } | ||
98 | + | ||
99 | + public override void Remove(Component component) | ||
100 | + { | ||
101 | + _children.Remove(component); | ||
102 | + } | ||
103 | + | ||
104 | + public override void Display(int depth) | ||
105 | + { | ||
106 | + Console.WriteLine(new String('-', depth) + name); | ||
107 | + | ||
108 | + // Recursively display child nodes | ||
109 | + | ||
110 | + foreach (Component component in _children) | ||
111 | + { | ||
112 | + component.Display(depth + 2); | ||
113 | + } | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + /// <summary> | ||
118 | + | ||
119 | + /// The 'Leaf' class | ||
120 | + | ||
121 | + /// </summary> | ||
122 | + | ||
123 | + class Leaf : Component | ||
124 | + { | ||
125 | + // Constructor | ||
126 | + | ||
127 | + public Leaf(string name) | ||
128 | + : base(name) | ||
129 | + { | ||
130 | + } | ||
131 | + | ||
132 | + public override void Add(Component c) | ||
133 | + { | ||
134 | + Console.WriteLine("Cannot add to a leaf"); | ||
135 | + } | ||
136 | + | ||
137 | + public override void Remove(Component c) | ||
138 | + { | ||
139 | + Console.WriteLine("Cannot remove from a leaf"); | ||
140 | + } | ||
141 | + | ||
142 | + public override void Display(int depth) | ||
143 | + { | ||
144 | + Console.WriteLine(new String('-', depth) + name); | ||
145 | + } | ||
146 | + } | ||
147 | +} |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Composite")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Composite")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("a5af7192-8c50-4a4c-9dc9-0d530650e677")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\bin\Debug\Composite.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\bin\Debug\Composite.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\obj\x86\Debug\Composite.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\obj\x86\Debug\Composite.pdb |
No preview for this file type
No preview for this file type
No preview for this file type
Design Patterns/Decorator/Decorator.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Decorator</RootNamespace> | ||
12 | + <AssemblyName>Decorator</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
50 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
51 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
52 | + <Target Name="BeforeBuild"> | ||
53 | + </Target> | ||
54 | + <Target Name="AfterBuild"> | ||
55 | + </Target> | ||
56 | + --> | ||
57 | +</Project> |
Design Patterns/Decorator/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Decorator | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Decorator Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + | ||
16 | + class MainApp | ||
17 | + { | ||
18 | + /// <summary> | ||
19 | + | ||
20 | + /// Entry point into console application. | ||
21 | + | ||
22 | + /// </summary> | ||
23 | + | ||
24 | + static void Main() | ||
25 | + { | ||
26 | + // Create ConcreteComponent and two Decorators | ||
27 | + | ||
28 | + ConcreteComponent c = new ConcreteComponent(); | ||
29 | + ConcreteDecoratorA d1 = new ConcreteDecoratorA(); | ||
30 | + ConcreteDecoratorB d2 = new ConcreteDecoratorB(); | ||
31 | + | ||
32 | + // Link decorators | ||
33 | + | ||
34 | + d1.SetComponent(c); | ||
35 | + d2.SetComponent(d1); | ||
36 | + | ||
37 | + d2.Operation(); | ||
38 | + | ||
39 | + // Wait for user | ||
40 | + | ||
41 | + Console.ReadKey(); | ||
42 | + } | ||
43 | + } | ||
44 | + | ||
45 | + /// <summary> | ||
46 | + | ||
47 | + /// The 'Component' abstract class | ||
48 | + | ||
49 | + /// </summary> | ||
50 | + | ||
51 | + abstract class Component | ||
52 | + { | ||
53 | + public abstract void Operation(); | ||
54 | + } | ||
55 | + | ||
56 | + /// <summary> | ||
57 | + | ||
58 | + /// The 'ConcreteComponent' class | ||
59 | + | ||
60 | + /// </summary> | ||
61 | + | ||
62 | + class ConcreteComponent : Component | ||
63 | + { | ||
64 | + public override void Operation() | ||
65 | + { | ||
66 | + Console.WriteLine("ConcreteComponent.Operation()"); | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
70 | + /// <summary> | ||
71 | + | ||
72 | + /// The 'Decorator' abstract class | ||
73 | + | ||
74 | + /// </summary> | ||
75 | + | ||
76 | + abstract class Decorator : Component | ||
77 | + { | ||
78 | + protected Component component; | ||
79 | + | ||
80 | + public void SetComponent(Component component) | ||
81 | + { | ||
82 | + this.component = component; | ||
83 | + } | ||
84 | + | ||
85 | + public override void Operation() | ||
86 | + { | ||
87 | + if (component != null) | ||
88 | + { | ||
89 | + component.Operation(); | ||
90 | + } | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + /// <summary> | ||
95 | + | ||
96 | + /// The 'ConcreteDecoratorA' class | ||
97 | + | ||
98 | + /// </summary> | ||
99 | + | ||
100 | + class ConcreteDecoratorA : Decorator | ||
101 | + { | ||
102 | + public override void Operation() | ||
103 | + { | ||
104 | + base.Operation(); | ||
105 | + Console.WriteLine("ConcreteDecoratorA.Operation()"); | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + /// <summary> | ||
110 | + | ||
111 | + /// The 'ConcreteDecoratorB' class | ||
112 | + | ||
113 | + /// </summary> | ||
114 | + | ||
115 | + class ConcreteDecoratorB : Decorator | ||
116 | + { | ||
117 | + public override void Operation() | ||
118 | + { | ||
119 | + base.Operation(); | ||
120 | + AddedBehavior(); | ||
121 | + Console.WriteLine("ConcreteDecoratorB.Operation()"); | ||
122 | + } | ||
123 | + | ||
124 | + void AddedBehavior() | ||
125 | + { | ||
126 | + } | ||
127 | + } | ||
128 | +} | ||
129 | + |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Decorator")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Decorator")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("5274830d-b555-4ec3-872e-c97979c3dac2")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\bin\Debug\Decorator.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\bin\Debug\Decorator.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\obj\x86\Debug\Decorator.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\obj\x86\Debug\Decorator.pdb |
No preview for this file type
No preview for this file type
No preview for this file type
Design Patterns/Design Patterns.sln
0 → 100644
1 | + | ||
2 | +Microsoft Visual Studio Solution File, Format Version 11.00 | ||
3 | +# Visual Studio 2010 | ||
4 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abstract Factory", "Abstract Factory\Abstract Factory.csproj", "{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}" | ||
5 | +EndProject | ||
6 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{50C2CC17-B3BC-4DB3-8901-24D18B757C23}" | ||
7 | +EndProject | ||
8 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Factory Method", "Factory Method\Factory Method.csproj", "{E332E255-A604-4C4C-A08C-2D6C9295C5D2}" | ||
9 | +EndProject | ||
10 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prototype.csproj", "{79BAA664-FC5B-4570-BC38-72DC6E4277CB}" | ||
11 | +EndProject | ||
12 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Singleton\Singleton.csproj", "{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}" | ||
13 | +EndProject | ||
14 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{0267B2D7-39C6-4C11-90FF-540527EF457A}" | ||
15 | +EndProject | ||
16 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bridge", "Bridge\Bridge.csproj", "{B5700B60-C82F-4765-9695-CE0B43BCA5D7}" | ||
17 | +EndProject | ||
18 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "Composite\Composite.csproj", "{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}" | ||
19 | +EndProject | ||
20 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decorator", "Decorator\Decorator.csproj", "{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}" | ||
21 | +EndProject | ||
22 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facade", "Facade\Facade.csproj", "{0C8C49C6-9121-49CC-9012-A1A627C2E960}" | ||
23 | +EndProject | ||
24 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flyweight", "Flyweight\Flyweight.csproj", "{66E86937-D762-4BF4-A0D6-317E9F76D3E8}" | ||
25 | +EndProject | ||
26 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proxy", "Proxy\Proxy.csproj", "{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}" | ||
27 | +EndProject | ||
28 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chain of Responsibility", "Chain of Responsibility\Chain of Responsibility.csproj", "{1FDCC993-010F-4E94-BA56-EF52EB9D8397}" | ||
29 | +EndProject | ||
30 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Command", "Command\Command.csproj", "{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}" | ||
31 | +EndProject | ||
32 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interpreter", "Interpreter\Interpreter.csproj", "{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}" | ||
33 | +EndProject | ||
34 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iterator", "Iterator\Iterator.csproj", "{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}" | ||
35 | +EndProject | ||
36 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mediator", "Mediator\Mediator.csproj", "{26D2883D-0BFD-4D94-AF1E-12C4FD508478}" | ||
37 | +EndProject | ||
38 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Memento", "Memento\Memento.csproj", "{922D79D0-8F3B-4C34-8E46-8DD24778F736}" | ||
39 | +EndProject | ||
40 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Observer", "Observer\Observer.csproj", "{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}" | ||
41 | +EndProject | ||
42 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "State", "State\State.csproj", "{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}" | ||
43 | +EndProject | ||
44 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strategy", "Strategy\Strategy.csproj", "{7AD5BC76-49BE-4700-85FA-DF869151B66C}" | ||
45 | +EndProject | ||
46 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Template Method", "Template Method\Template Method.csproj", "{2A8BF715-1168-428D-869F-485CB4DEB671}" | ||
47 | +EndProject | ||
48 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Visitor", "Visitor\Visitor.csproj", "{148422F3-1363-4839-8D27-FD9CE37A9641}" | ||
49 | +EndProject | ||
50 | +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Creational Patterns", "Creational Patterns", "{1F110E75-AF31-4330-9090-89279E0814E0}" | ||
51 | +EndProject | ||
52 | +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Structural Patterns", "Structural Patterns", "{28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}" | ||
53 | +EndProject | ||
54 | +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Behavioral Patterns", "Behavioral Patterns", "{DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}" | ||
55 | +EndProject | ||
56 | +Global | ||
57 | + GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
58 | + Debug|x86 = Debug|x86 | ||
59 | + Release|x86 = Release|x86 | ||
60 | + EndGlobalSection | ||
61 | + GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
62 | + {EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Debug|x86.ActiveCfg = Debug|x86 | ||
63 | + {EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Debug|x86.Build.0 = Debug|x86 | ||
64 | + {EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Release|x86.ActiveCfg = Release|x86 | ||
65 | + {EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Release|x86.Build.0 = Release|x86 | ||
66 | + {50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Debug|x86.ActiveCfg = Debug|x86 | ||
67 | + {50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Debug|x86.Build.0 = Debug|x86 | ||
68 | + {50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Release|x86.ActiveCfg = Release|x86 | ||
69 | + {50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Release|x86.Build.0 = Release|x86 | ||
70 | + {E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Debug|x86.ActiveCfg = Debug|x86 | ||
71 | + {E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Debug|x86.Build.0 = Debug|x86 | ||
72 | + {E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Release|x86.ActiveCfg = Release|x86 | ||
73 | + {E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Release|x86.Build.0 = Release|x86 | ||
74 | + {79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Debug|x86.ActiveCfg = Debug|x86 | ||
75 | + {79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Debug|x86.Build.0 = Debug|x86 | ||
76 | + {79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Release|x86.ActiveCfg = Release|x86 | ||
77 | + {79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Release|x86.Build.0 = Release|x86 | ||
78 | + {0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Debug|x86.ActiveCfg = Debug|x86 | ||
79 | + {0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Debug|x86.Build.0 = Debug|x86 | ||
80 | + {0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Release|x86.ActiveCfg = Release|x86 | ||
81 | + {0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Release|x86.Build.0 = Release|x86 | ||
82 | + {0267B2D7-39C6-4C11-90FF-540527EF457A}.Debug|x86.ActiveCfg = Debug|x86 | ||
83 | + {0267B2D7-39C6-4C11-90FF-540527EF457A}.Debug|x86.Build.0 = Debug|x86 | ||
84 | + {0267B2D7-39C6-4C11-90FF-540527EF457A}.Release|x86.ActiveCfg = Release|x86 | ||
85 | + {0267B2D7-39C6-4C11-90FF-540527EF457A}.Release|x86.Build.0 = Release|x86 | ||
86 | + {B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Debug|x86.ActiveCfg = Debug|x86 | ||
87 | + {B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Debug|x86.Build.0 = Debug|x86 | ||
88 | + {B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Release|x86.ActiveCfg = Release|x86 | ||
89 | + {B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Release|x86.Build.0 = Release|x86 | ||
90 | + {D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Debug|x86.ActiveCfg = Debug|x86 | ||
91 | + {D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Debug|x86.Build.0 = Debug|x86 | ||
92 | + {D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Release|x86.ActiveCfg = Release|x86 | ||
93 | + {D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Release|x86.Build.0 = Release|x86 | ||
94 | + {10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Debug|x86.ActiveCfg = Debug|x86 | ||
95 | + {10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Debug|x86.Build.0 = Debug|x86 | ||
96 | + {10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Release|x86.ActiveCfg = Release|x86 | ||
97 | + {10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Release|x86.Build.0 = Release|x86 | ||
98 | + {0C8C49C6-9121-49CC-9012-A1A627C2E960}.Debug|x86.ActiveCfg = Debug|x86 | ||
99 | + {0C8C49C6-9121-49CC-9012-A1A627C2E960}.Debug|x86.Build.0 = Debug|x86 | ||
100 | + {0C8C49C6-9121-49CC-9012-A1A627C2E960}.Release|x86.ActiveCfg = Release|x86 | ||
101 | + {0C8C49C6-9121-49CC-9012-A1A627C2E960}.Release|x86.Build.0 = Release|x86 | ||
102 | + {66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Debug|x86.ActiveCfg = Debug|x86 | ||
103 | + {66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Debug|x86.Build.0 = Debug|x86 | ||
104 | + {66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Release|x86.ActiveCfg = Release|x86 | ||
105 | + {66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Release|x86.Build.0 = Release|x86 | ||
106 | + {97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Debug|x86.ActiveCfg = Debug|x86 | ||
107 | + {97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Debug|x86.Build.0 = Debug|x86 | ||
108 | + {97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Release|x86.ActiveCfg = Release|x86 | ||
109 | + {97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Release|x86.Build.0 = Release|x86 | ||
110 | + {1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Debug|x86.ActiveCfg = Debug|x86 | ||
111 | + {1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Debug|x86.Build.0 = Debug|x86 | ||
112 | + {1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Release|x86.ActiveCfg = Release|x86 | ||
113 | + {1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Release|x86.Build.0 = Release|x86 | ||
114 | + {554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Debug|x86.ActiveCfg = Debug|x86 | ||
115 | + {554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Debug|x86.Build.0 = Debug|x86 | ||
116 | + {554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Release|x86.ActiveCfg = Release|x86 | ||
117 | + {554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Release|x86.Build.0 = Release|x86 | ||
118 | + {2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Debug|x86.ActiveCfg = Debug|x86 | ||
119 | + {2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Debug|x86.Build.0 = Debug|x86 | ||
120 | + {2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Release|x86.ActiveCfg = Release|x86 | ||
121 | + {2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Release|x86.Build.0 = Release|x86 | ||
122 | + {21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Debug|x86.ActiveCfg = Debug|x86 | ||
123 | + {21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Debug|x86.Build.0 = Debug|x86 | ||
124 | + {21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Release|x86.ActiveCfg = Release|x86 | ||
125 | + {21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Release|x86.Build.0 = Release|x86 | ||
126 | + {26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Debug|x86.ActiveCfg = Debug|x86 | ||
127 | + {26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Debug|x86.Build.0 = Debug|x86 | ||
128 | + {26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Release|x86.ActiveCfg = Release|x86 | ||
129 | + {26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Release|x86.Build.0 = Release|x86 | ||
130 | + {922D79D0-8F3B-4C34-8E46-8DD24778F736}.Debug|x86.ActiveCfg = Debug|x86 | ||
131 | + {922D79D0-8F3B-4C34-8E46-8DD24778F736}.Debug|x86.Build.0 = Debug|x86 | ||
132 | + {922D79D0-8F3B-4C34-8E46-8DD24778F736}.Release|x86.ActiveCfg = Release|x86 | ||
133 | + {922D79D0-8F3B-4C34-8E46-8DD24778F736}.Release|x86.Build.0 = Release|x86 | ||
134 | + {76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Debug|x86.ActiveCfg = Debug|x86 | ||
135 | + {76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Debug|x86.Build.0 = Debug|x86 | ||
136 | + {76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Release|x86.ActiveCfg = Release|x86 | ||
137 | + {76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Release|x86.Build.0 = Release|x86 | ||
138 | + {93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Debug|x86.ActiveCfg = Debug|x86 | ||
139 | + {93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Debug|x86.Build.0 = Debug|x86 | ||
140 | + {93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Release|x86.ActiveCfg = Release|x86 | ||
141 | + {93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Release|x86.Build.0 = Release|x86 | ||
142 | + {7AD5BC76-49BE-4700-85FA-DF869151B66C}.Debug|x86.ActiveCfg = Debug|x86 | ||
143 | + {7AD5BC76-49BE-4700-85FA-DF869151B66C}.Debug|x86.Build.0 = Debug|x86 | ||
144 | + {7AD5BC76-49BE-4700-85FA-DF869151B66C}.Release|x86.ActiveCfg = Release|x86 | ||
145 | + {7AD5BC76-49BE-4700-85FA-DF869151B66C}.Release|x86.Build.0 = Release|x86 | ||
146 | + {2A8BF715-1168-428D-869F-485CB4DEB671}.Debug|x86.ActiveCfg = Debug|x86 | ||
147 | + {2A8BF715-1168-428D-869F-485CB4DEB671}.Debug|x86.Build.0 = Debug|x86 | ||
148 | + {2A8BF715-1168-428D-869F-485CB4DEB671}.Release|x86.ActiveCfg = Release|x86 | ||
149 | + {2A8BF715-1168-428D-869F-485CB4DEB671}.Release|x86.Build.0 = Release|x86 | ||
150 | + {148422F3-1363-4839-8D27-FD9CE37A9641}.Debug|x86.ActiveCfg = Debug|x86 | ||
151 | + {148422F3-1363-4839-8D27-FD9CE37A9641}.Debug|x86.Build.0 = Debug|x86 | ||
152 | + {148422F3-1363-4839-8D27-FD9CE37A9641}.Release|x86.ActiveCfg = Release|x86 | ||
153 | + {148422F3-1363-4839-8D27-FD9CE37A9641}.Release|x86.Build.0 = Release|x86 | ||
154 | + EndGlobalSection | ||
155 | + GlobalSection(SolutionProperties) = preSolution | ||
156 | + HideSolutionNode = FALSE | ||
157 | + EndGlobalSection | ||
158 | + GlobalSection(NestedProjects) = preSolution | ||
159 | + {EF50FA49-7F7A-4CE8-B828-918A56BD3CA0} = {1F110E75-AF31-4330-9090-89279E0814E0} | ||
160 | + {50C2CC17-B3BC-4DB3-8901-24D18B757C23} = {1F110E75-AF31-4330-9090-89279E0814E0} | ||
161 | + {E332E255-A604-4C4C-A08C-2D6C9295C5D2} = {1F110E75-AF31-4330-9090-89279E0814E0} | ||
162 | + {0F6A0D37-4735-474E-B027-8F8B9E52CC5A} = {1F110E75-AF31-4330-9090-89279E0814E0} | ||
163 | + {79BAA664-FC5B-4570-BC38-72DC6E4277CB} = {1F110E75-AF31-4330-9090-89279E0814E0} | ||
164 | + {0267B2D7-39C6-4C11-90FF-540527EF457A} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
165 | + {B5700B60-C82F-4765-9695-CE0B43BCA5D7} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
166 | + {D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
167 | + {10D7BF70-5C45-4A22-8BC3-FEFA6B122756} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
168 | + {0C8C49C6-9121-49CC-9012-A1A627C2E960} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
169 | + {66E86937-D762-4BF4-A0D6-317E9F76D3E8} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
170 | + {97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05} | ||
171 | + {1FDCC993-010F-4E94-BA56-EF52EB9D8397} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
172 | + {554DD1E6-AF06-43D6-8736-9A6CBB8379A8} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
173 | + {2356D5AD-BF8E-4B84-B929-DBD245AC38CF} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
174 | + {21BBBCF0-F9D8-4035-BAFA-967C3D18E34C} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
175 | + {26D2883D-0BFD-4D94-AF1E-12C4FD508478} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
176 | + {922D79D0-8F3B-4C34-8E46-8DD24778F736} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
177 | + {76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
178 | + {93FB6650-CE0F-44BD-B894-1D5CC38ECBF5} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
179 | + {7AD5BC76-49BE-4700-85FA-DF869151B66C} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
180 | + {2A8BF715-1168-428D-869F-485CB4DEB671} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
181 | + {148422F3-1363-4839-8D27-FD9CE37A9641} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69} | ||
182 | + EndGlobalSection | ||
183 | +EndGlobal |
Design Patterns/Design Patterns.suo
0 → 100644
No preview for this file type
Design Patterns/Facade/Facade.csproj
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{0C8C49C6-9121-49CC-9012-A1A627C2E960}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Facade</RootNamespace> | ||
12 | + <AssemblyName>Facade</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
50 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
51 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
52 | + <Target Name="BeforeBuild"> | ||
53 | + </Target> | ||
54 | + <Target Name="AfterBuild"> | ||
55 | + </Target> | ||
56 | + --> | ||
57 | +</Project> |
Design Patterns/Facade/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +//Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use. | ||
7 | + | ||
8 | +namespace Facade | ||
9 | +{ | ||
10 | + /// <summary> | ||
11 | + | ||
12 | + /// MainApp startup class for Structural | ||
13 | + | ||
14 | + /// Facade Design Pattern. | ||
15 | + | ||
16 | + /// </summary> | ||
17 | + | ||
18 | + class MainApp | ||
19 | + { | ||
20 | + /// <summary> | ||
21 | + | ||
22 | + /// Entry point into console application. | ||
23 | + | ||
24 | + /// </summary> | ||
25 | + | ||
26 | + public static void Main() | ||
27 | + { | ||
28 | + Facade facade = new Facade(); | ||
29 | + | ||
30 | + facade.MethodA(); | ||
31 | + facade.MethodB(); | ||
32 | + | ||
33 | + // Wait for user | ||
34 | + | ||
35 | + Console.ReadKey(); | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + /// <summary> | ||
40 | + | ||
41 | + /// The 'Subsystem ClassA' class | ||
42 | + | ||
43 | + /// </summary> | ||
44 | + | ||
45 | + class SubSystemOne | ||
46 | + { | ||
47 | + public void MethodOne() | ||
48 | + { | ||
49 | + Console.WriteLine(" SubSystemOne Method"); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + /// <summary> | ||
54 | + | ||
55 | + /// The 'Subsystem ClassB' class | ||
56 | + | ||
57 | + /// </summary> | ||
58 | + | ||
59 | + class SubSystemTwo | ||
60 | + { | ||
61 | + public void MethodTwo() | ||
62 | + { | ||
63 | + Console.WriteLine(" SubSystemTwo Method"); | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + /// <summary> | ||
68 | + | ||
69 | + /// The 'Subsystem ClassC' class | ||
70 | + | ||
71 | + /// </summary> | ||
72 | + | ||
73 | + class SubSystemThree | ||
74 | + { | ||
75 | + public void MethodThree() | ||
76 | + { | ||
77 | + Console.WriteLine(" SubSystemThree Method"); | ||
78 | + } | ||
79 | + } | ||
80 | + | ||
81 | + /// <summary> | ||
82 | + | ||
83 | + /// The 'Subsystem ClassD' class | ||
84 | + | ||
85 | + /// </summary> | ||
86 | + | ||
87 | + class SubSystemFour | ||
88 | + { | ||
89 | + public void MethodFour() | ||
90 | + { | ||
91 | + Console.WriteLine(" SubSystemFour Method"); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /// <summary> | ||
96 | + | ||
97 | + /// The 'Facade' class | ||
98 | + | ||
99 | + /// </summary> | ||
100 | + | ||
101 | + class Facade | ||
102 | + { | ||
103 | + private SubSystemOne _one; | ||
104 | + private SubSystemTwo _two; | ||
105 | + private SubSystemThree _three; | ||
106 | + private SubSystemFour _four; | ||
107 | + | ||
108 | + public Facade() | ||
109 | + { | ||
110 | + _one = new SubSystemOne(); | ||
111 | + _two = new SubSystemTwo(); | ||
112 | + _three = new SubSystemThree(); | ||
113 | + _four = new SubSystemFour(); | ||
114 | + } | ||
115 | + | ||
116 | + public void MethodA() | ||
117 | + { | ||
118 | + Console.WriteLine("\nMethodA() ---- "); | ||
119 | + _one.MethodOne(); | ||
120 | + _two.MethodTwo(); | ||
121 | + _four.MethodFour(); | ||
122 | + } | ||
123 | + | ||
124 | + public void MethodB() | ||
125 | + { | ||
126 | + Console.WriteLine("\nMethodB() ---- "); | ||
127 | + _two.MethodTwo(); | ||
128 | + _three.MethodThree(); | ||
129 | + } | ||
130 | + } | ||
131 | +} | ||
132 | + |
1 | +using System.Reflection; | ||
2 | +using System.Runtime.CompilerServices; | ||
3 | +using System.Runtime.InteropServices; | ||
4 | + | ||
5 | +// General Information about an assembly is controlled through the following | ||
6 | +// set of attributes. Change these attribute values to modify the information | ||
7 | +// associated with an assembly. | ||
8 | +[assembly: AssemblyTitle("Facade")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Facade")] | ||
13 | +[assembly: AssemblyCopyright("Copyright © Microsoft 2018")] | ||
14 | +[assembly: AssemblyTrademark("")] | ||
15 | +[assembly: AssemblyCulture("")] | ||
16 | + | ||
17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
18 | +// to COM components. If you need to access a type in this assembly from | ||
19 | +// COM, set the ComVisible attribute to true on that type. | ||
20 | +[assembly: ComVisible(false)] | ||
21 | + | ||
22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | +[assembly: Guid("b5d9620b-5a16-4b64-b023-eb7220e30e95")] | ||
24 | + | ||
25 | +// Version information for an assembly consists of the following four values: | ||
26 | +// | ||
27 | +// Major Version | ||
28 | +// Minor Version | ||
29 | +// Build Number | ||
30 | +// Revision | ||
31 | +// | ||
32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
33 | +// by using the '*' as shown below: | ||
34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
Design Patterns/Facade/bin/Debug/Facade.exe
0 → 100644
No preview for this file type
Design Patterns/Facade/bin/Debug/Facade.pdb
0 → 100644
No preview for this file type
No preview for this file type
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
3 | + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
4 | + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
5 | + <security> | ||
6 | + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
7 | + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
8 | + </requestedPrivileges> | ||
9 | + </security> | ||
10 | + </trustInfo> | ||
11 | +</assembly> |
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\bin\Debug\Facade.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\bin\Debug\Facade.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\obj\x86\Debug\Facade.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\obj\x86\Debug\Facade.pdb |
No preview for this file type
No preview for this file type
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | + <PropertyGroup> | ||
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
6 | + <ProductVersion>8.0.30703</ProductVersion> | ||
7 | + <SchemaVersion>2.0</SchemaVersion> | ||
8 | + <ProjectGuid>{E332E255-A604-4C4C-A08C-2D6C9295C5D2}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Factory_Method</RootNamespace> | ||
12 | + <AssemblyName>Factory Method</AssemblyName> | ||
13 | + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
14 | + <TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
15 | + <FileAlignment>512</FileAlignment> | ||
16 | + </PropertyGroup> | ||
17 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
18 | + <PlatformTarget>x86</PlatformTarget> | ||
19 | + <DebugSymbols>true</DebugSymbols> | ||
20 | + <DebugType>full</DebugType> | ||
21 | + <Optimize>false</Optimize> | ||
22 | + <OutputPath>bin\Debug\</OutputPath> | ||
23 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
24 | + <ErrorReport>prompt</ErrorReport> | ||
25 | + <WarningLevel>4</WarningLevel> | ||
26 | + </PropertyGroup> | ||
27 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
28 | + <PlatformTarget>x86</PlatformTarget> | ||
29 | + <DebugType>pdbonly</DebugType> | ||
30 | + <Optimize>true</Optimize> | ||
31 | + <OutputPath>bin\Release\</OutputPath> | ||
32 | + <DefineConstants>TRACE</DefineConstants> | ||
33 | + <ErrorReport>prompt</ErrorReport> | ||
34 | + <WarningLevel>4</WarningLevel> | ||
35 | + </PropertyGroup> | ||
36 | + <ItemGroup> | ||
37 | + <Reference Include="System" /> | ||
38 | + <Reference Include="System.Core" /> | ||
39 | + <Reference Include="System.Xml.Linq" /> | ||
40 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
41 | + <Reference Include="Microsoft.CSharp" /> | ||
42 | + <Reference Include="System.Data" /> | ||
43 | + <Reference Include="System.Xml" /> | ||
44 | + </ItemGroup> | ||
45 | + <ItemGroup> | ||
46 | + <Compile Include="Program.cs" /> | ||
47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
48 | + </ItemGroup> | ||
49 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
50 | + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
51 | + Other similar extension points exist, see Microsoft.Common.targets. | ||
52 | + <Target Name="BeforeBuild"> | ||
53 | + </Target> | ||
54 | + <Target Name="AfterBuild"> | ||
55 | + </Target> | ||
56 | + --> | ||
57 | +</Project> |
Design Patterns/Factory Method/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Factory_Method | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Factory Method Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + | ||
16 | + class MainApp | ||
17 | + { | ||
18 | + /// <summary> | ||
19 | + | ||
20 | + /// Entry point into console application. | ||
21 | + | ||
22 | + /// </summary> | ||
23 | + | ||
24 | + static void Main() | ||
25 | + { | ||
26 | + // An array of creators | ||
27 | + | ||
28 | + Creator[] creators = new Creator[2]; | ||
29 | + | ||
30 | + creators[0] = new ConcreteCreatorA(); | ||
31 | + creators[1] = new ConcreteCreatorB(); | ||
32 | + | ||
33 | + // Iterate over creators and create products | ||
34 | + | ||
35 | + foreach (Creator creator in creators) | ||
36 | + { | ||
37 | + Product product = creator.FactoryMethod(); | ||
38 | + Console.WriteLine("Created {0}", | ||
39 | + product.GetType().Name); | ||
40 | + } | ||
41 | + | ||
42 | + // Wait for user | ||
43 | + | ||
44 | + Console.ReadKey(); | ||
45 | + } | ||
46 | + } | ||
47 | + | ||
48 | + /// <summary> | ||
49 | + | ||
50 | + /// The 'Product' abstract class | ||
51 | + | ||
52 | + /// </summary> | ||
53 | + | ||
54 | + abstract class Product | ||
55 | + { | ||
56 | + } | ||
57 | + | ||
58 | + /// <summary> | ||
59 | + | ||
60 | + /// A 'ConcreteProduct' class | ||
61 | + | ||
62 | + /// </summary> | ||
63 | + | ||
64 | + class ConcreteProductA : Product | ||
65 | + { | ||
66 | + } | ||
67 | + | ||
68 | + /// <summary> | ||
69 | + | ||
70 | + /// A 'ConcreteProduct' class | ||
71 | + | ||
72 | + /// </summary> | ||
73 | + | ||
74 | + class ConcreteProductB : Product | ||
75 | + { | ||
76 | + } | ||
77 | + | ||
78 | + /// <summary> | ||
79 | + | ||
80 | + /// The 'Creator' abstract class | ||
81 | + | ||
82 | + /// </summary> | ||
83 | + | ||
84 | + abstract class Creator | ||
85 | + { | ||
86 | + public abstract Product FactoryMethod(); | ||
87 | + } | ||
88 | + | ||
89 | + /// <summary> | ||
90 | + | ||
91 | + /// A 'ConcreteCreator' class | ||
92 | + | ||
93 | + /// </summary> | ||
94 | + | ||
95 | + class ConcreteCreatorA : Creator | ||
96 | + { | ||
97 | + public override Product FactoryMethod() | ||
98 | + { | ||
99 | + return new ConcreteProductA(); | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + /// <summary> | ||
104 | + | ||
105 | + /// A 'ConcreteCreator' class | ||
106 | + | ||
107 | + /// </summary> | ||
108 | + | ||
109 | + class ConcreteCreatorB : Creator | ||
110 | + { | ||
111 | + public override Product FactoryMethod() | ||
112 | + { | ||
113 | + return new ConcreteProductB(); | ||
114 | + } | ||
115 | + } | ||
116 | +} |
-
Please register or login to post a comment