Commiting the Design Pattern Project
Showing
241 changed files
with
5557 additions
and
3 deletions
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 | +} |
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("Factory Method")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Factory Method")] | ||
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("4b7a4b8c-bdeb-43ef-a65e-4b29f5898c3a")] | ||
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/Factory Method/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
0 → 100644
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Factory Method\bin\Debug\Factory Method.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Factory Method\bin\Debug\Factory Method.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Factory Method\obj\x86\Debug\Factory Method.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Factory Method\obj\x86\Debug\Factory Method.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Flyweight/Flyweight.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>{66E86937-D762-4BF4-A0D6-317E9F76D3E8}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Flyweight</RootNamespace> | ||
12 | + <AssemblyName>Flyweight</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/Flyweight/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | +using System.Collections; | ||
6 | + | ||
7 | +namespace Flyweight | ||
8 | +{ | ||
9 | + /// <summary> | ||
10 | + | ||
11 | + /// MainApp startup class for Structural | ||
12 | + | ||
13 | + /// Flyweight Design Pattern. | ||
14 | + | ||
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 | + // Arbitrary extrinsic state | ||
28 | + | ||
29 | + int extrinsicstate = 22; | ||
30 | + | ||
31 | + FlyweightFactory factory = new FlyweightFactory(); | ||
32 | + | ||
33 | + // Work with different flyweight instances | ||
34 | + | ||
35 | + Flyweight fx = factory.GetFlyweight("X"); | ||
36 | + fx.Operation(--extrinsicstate); | ||
37 | + | ||
38 | + Flyweight fy = factory.GetFlyweight("Y"); | ||
39 | + fy.Operation(--extrinsicstate); | ||
40 | + | ||
41 | + Flyweight fz = factory.GetFlyweight("Z"); | ||
42 | + fz.Operation(--extrinsicstate); | ||
43 | + | ||
44 | + UnsharedConcreteFlyweight fu = new | ||
45 | + | ||
46 | + UnsharedConcreteFlyweight(); | ||
47 | + | ||
48 | + fu.Operation(--extrinsicstate); | ||
49 | + | ||
50 | + // Wait for user | ||
51 | + | ||
52 | + Console.ReadKey(); | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + /// <summary> | ||
57 | + | ||
58 | + /// The 'FlyweightFactory' class | ||
59 | + | ||
60 | + /// </summary> | ||
61 | + | ||
62 | + class FlyweightFactory | ||
63 | + { | ||
64 | + private Hashtable flyweights = new Hashtable(); | ||
65 | + | ||
66 | + // Constructor | ||
67 | + | ||
68 | + public FlyweightFactory() | ||
69 | + { | ||
70 | + flyweights.Add("X", new ConcreteFlyweight()); | ||
71 | + flyweights.Add("Y", new ConcreteFlyweight()); | ||
72 | + flyweights.Add("Z", new ConcreteFlyweight()); | ||
73 | + } | ||
74 | + | ||
75 | + public Flyweight GetFlyweight(string key) | ||
76 | + { | ||
77 | + return ((Flyweight)flyweights[key]); | ||
78 | + } | ||
79 | + } | ||
80 | + | ||
81 | + /// <summary> | ||
82 | + | ||
83 | + /// The 'Flyweight' abstract class | ||
84 | + | ||
85 | + /// </summary> | ||
86 | + | ||
87 | + abstract class Flyweight | ||
88 | + { | ||
89 | + public abstract void Operation(int extrinsicstate); | ||
90 | + } | ||
91 | + | ||
92 | + /// <summary> | ||
93 | + | ||
94 | + /// The 'ConcreteFlyweight' class | ||
95 | + | ||
96 | + /// </summary> | ||
97 | + | ||
98 | + class ConcreteFlyweight : Flyweight | ||
99 | + { | ||
100 | + public override void Operation(int extrinsicstate) | ||
101 | + { | ||
102 | + Console.WriteLine("ConcreteFlyweight: " + extrinsicstate); | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + /// <summary> | ||
107 | + | ||
108 | + /// The 'UnsharedConcreteFlyweight' class | ||
109 | + | ||
110 | + /// </summary> | ||
111 | + | ||
112 | + class UnsharedConcreteFlyweight : Flyweight | ||
113 | + { | ||
114 | + public override void Operation(int extrinsicstate) | ||
115 | + { | ||
116 | + Console.WriteLine("UnsharedConcreteFlyweight: " + | ||
117 | + extrinsicstate); | ||
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("Flyweight")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Flyweight")] | ||
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("fd5e48c0-21ef-49dc-9de9-350013914144")] | ||
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 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Flyweight\bin\Debug\Flyweight.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Flyweight\bin\Debug\Flyweight.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Flyweight\obj\x86\Debug\Flyweight.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Flyweight\obj\x86\Debug\Flyweight.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Interpreter/Intepreter.PNG
0 → 100644
12.5 KB
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>{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Interpreter</RootNamespace> | ||
12 | + <AssemblyName>Interpreter</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="Intepreter.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> |
Design Patterns/Interpreter/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | +using System.Collections; | ||
6 | + | ||
7 | +namespace Interpreter | ||
8 | +{ | ||
9 | + /// <summary> | ||
10 | + | ||
11 | + /// MainApp startup class for Structural | ||
12 | + | ||
13 | + /// Interpreter Design Pattern. | ||
14 | + | ||
15 | + /// </summary> | ||
16 | + /// | ||
17 | + //Given a language, define a representation for its grammar along with an | ||
18 | + //interpreter that uses the representation to interpret sentences in the language. | ||
19 | + | ||
20 | + class MainApp | ||
21 | + { | ||
22 | + /// <summary> | ||
23 | + | ||
24 | + /// Entry point into console application. | ||
25 | + | ||
26 | + /// </summary> | ||
27 | + | ||
28 | + static void Main() | ||
29 | + { | ||
30 | + Context context = new Context(); | ||
31 | + | ||
32 | + // Usually a tree | ||
33 | + | ||
34 | + ArrayList list = new ArrayList(); | ||
35 | + | ||
36 | + // Populate 'abstract syntax tree' | ||
37 | + | ||
38 | + list.Add(new TerminalExpression()); | ||
39 | + list.Add(new NonterminalExpression()); | ||
40 | + list.Add(new TerminalExpression()); | ||
41 | + list.Add(new TerminalExpression()); | ||
42 | + | ||
43 | + // Interpret | ||
44 | + | ||
45 | + foreach (AbstractExpression exp in list) | ||
46 | + { | ||
47 | + exp.Interpret(context); | ||
48 | + } | ||
49 | + | ||
50 | + // Wait for user | ||
51 | + | ||
52 | + Console.ReadKey(); | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + /// <summary> | ||
57 | + | ||
58 | + /// The 'Context' class | ||
59 | + | ||
60 | + /// </summary> | ||
61 | + | ||
62 | + class Context | ||
63 | + { | ||
64 | + } | ||
65 | + | ||
66 | + /// <summary> | ||
67 | + | ||
68 | + /// The 'AbstractExpression' abstract class | ||
69 | + | ||
70 | + /// </summary> | ||
71 | + | ||
72 | + abstract class AbstractExpression | ||
73 | + { | ||
74 | + public abstract void Interpret(Context context); | ||
75 | + } | ||
76 | + | ||
77 | + /// <summary> | ||
78 | + | ||
79 | + /// The 'TerminalExpression' class | ||
80 | + | ||
81 | + /// </summary> | ||
82 | + | ||
83 | + class TerminalExpression : AbstractExpression | ||
84 | + { | ||
85 | + public override void Interpret(Context context) | ||
86 | + { | ||
87 | + Console.WriteLine("Called Terminal.Interpret()"); | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + /// <summary> | ||
92 | + | ||
93 | + /// The 'NonterminalExpression' class | ||
94 | + | ||
95 | + /// </summary> | ||
96 | + | ||
97 | + class NonterminalExpression : AbstractExpression | ||
98 | + { | ||
99 | + public override void Interpret(Context context) | ||
100 | + { | ||
101 | + Console.WriteLine("Called Nonterminal.Interpret()"); | ||
102 | + } | ||
103 | + } | ||
104 | +} |
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("Interpreter")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Interpreter")] | ||
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("2cd3132e-725e-46a1-88d1-2e6f5b414a92")] | ||
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 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Interpreter\bin\Debug\Interpreter.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Interpreter\bin\Debug\Interpreter.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Interpreter\obj\x86\Debug\Interpreter.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Interpreter\obj\x86\Debug\Interpreter.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Iterator/Iteration.PNG
0 → 100644
13.7 KB
Design Patterns/Iterator/Iterator.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>{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Iterator</RootNamespace> | ||
12 | + <AssemblyName>Iterator</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="Iteration.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> |
Design Patterns/Iterator/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | +using System.Collections; | ||
6 | + | ||
7 | +namespace Iterator | ||
8 | +{ | ||
9 | + | ||
10 | + /// <summary> | ||
11 | + | ||
12 | + /// MainApp startup class for Structural | ||
13 | + | ||
14 | + /// Iterator Design Pattern. | ||
15 | + | ||
16 | + /// </summary> | ||
17 | + /// | ||
18 | + //Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. | ||
19 | + | ||
20 | + class MainApp | ||
21 | + { | ||
22 | + /// <summary> | ||
23 | + | ||
24 | + /// Entry point into console application. | ||
25 | + | ||
26 | + /// </summary> | ||
27 | + | ||
28 | + static void Main() | ||
29 | + { | ||
30 | + ConcreteAggregate a = new ConcreteAggregate(); | ||
31 | + a[0] = "Item A"; | ||
32 | + a[1] = "Item B"; | ||
33 | + a[2] = "Item C"; | ||
34 | + a[3] = "Item D"; | ||
35 | + | ||
36 | + // Create Iterator and provide aggregate | ||
37 | + | ||
38 | + Iterator i = a.CreateIterator(); | ||
39 | + | ||
40 | + Console.WriteLine("Iterating over collection:"); | ||
41 | + | ||
42 | + object item = i.First(); | ||
43 | + while (item != null) | ||
44 | + { | ||
45 | + Console.WriteLine(item); | ||
46 | + item = i.Next(); | ||
47 | + } | ||
48 | + | ||
49 | + // Wait for user | ||
50 | + | ||
51 | + Console.ReadKey(); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + /// <summary> | ||
56 | + | ||
57 | + /// The 'Aggregate' abstract class | ||
58 | + | ||
59 | + /// </summary> | ||
60 | + | ||
61 | + abstract class Aggregate | ||
62 | + { | ||
63 | + public abstract Iterator CreateIterator(); | ||
64 | + } | ||
65 | + | ||
66 | + /// <summary> | ||
67 | + | ||
68 | + /// The 'ConcreteAggregate' class | ||
69 | + | ||
70 | + /// </summary> | ||
71 | + | ||
72 | + class ConcreteAggregate : Aggregate | ||
73 | + { | ||
74 | + private ArrayList _items = new ArrayList(); | ||
75 | + | ||
76 | + public override Iterator CreateIterator() | ||
77 | + { | ||
78 | + return new ConcreteIterator(this); | ||
79 | + } | ||
80 | + | ||
81 | + // Gets item count | ||
82 | + | ||
83 | + public int Count | ||
84 | + { | ||
85 | + get { return _items.Count; } | ||
86 | + } | ||
87 | + | ||
88 | + // Indexer | ||
89 | + | ||
90 | + public object this[int index] | ||
91 | + { | ||
92 | + get { return _items[index]; } | ||
93 | + set { _items.Insert(index, value); } | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + /// <summary> | ||
98 | + | ||
99 | + /// The 'Iterator' abstract class | ||
100 | + | ||
101 | + /// </summary> | ||
102 | + | ||
103 | + abstract class Iterator | ||
104 | + { | ||
105 | + public abstract object First(); | ||
106 | + public abstract object Next(); | ||
107 | + public abstract bool IsDone(); | ||
108 | + public abstract object CurrentItem(); | ||
109 | + } | ||
110 | + | ||
111 | + /// <summary> | ||
112 | + | ||
113 | + /// The 'ConcreteIterator' class | ||
114 | + | ||
115 | + /// </summary> | ||
116 | + | ||
117 | + class ConcreteIterator : Iterator | ||
118 | + { | ||
119 | + private ConcreteAggregate _aggregate; | ||
120 | + private int _current = 0; | ||
121 | + | ||
122 | + // Constructor | ||
123 | + | ||
124 | + public ConcreteIterator(ConcreteAggregate aggregate) | ||
125 | + { | ||
126 | + this._aggregate = aggregate; | ||
127 | + } | ||
128 | + | ||
129 | + // Gets first iteration item | ||
130 | + | ||
131 | + public override object First() | ||
132 | + { | ||
133 | + return _aggregate[0]; | ||
134 | + } | ||
135 | + | ||
136 | + // Gets next iteration item | ||
137 | + | ||
138 | + public override object Next() | ||
139 | + { | ||
140 | + object ret = null; | ||
141 | + if (_current < _aggregate.Count - 1) | ||
142 | + { | ||
143 | + ret = _aggregate[++_current]; | ||
144 | + } | ||
145 | + | ||
146 | + return ret; | ||
147 | + } | ||
148 | + | ||
149 | + // Gets current iteration item | ||
150 | + | ||
151 | + public override object CurrentItem() | ||
152 | + { | ||
153 | + return _aggregate[_current]; | ||
154 | + } | ||
155 | + | ||
156 | + // Gets whether iterations are complete | ||
157 | + | ||
158 | + public override bool IsDone() | ||
159 | + { | ||
160 | + return _current >= _aggregate.Count; | ||
161 | + } | ||
162 | + } | ||
163 | +} |
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("Iterator")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Iterator")] | ||
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("52d570cb-07fd-42e1-a9e8-f50ba61d01cc")] | ||
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> |
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Iterator\bin\Debug\Iterator.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Iterator\bin\Debug\Iterator.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Iterator\obj\x86\Debug\Iterator.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Iterator\obj\x86\Debug\Iterator.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Mediator/Mediator.PNG
0 → 100644
10.1 KB
Design Patterns/Mediator/Mediator.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>{26D2883D-0BFD-4D94-AF1E-12C4FD508478}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Mediator</RootNamespace> | ||
12 | + <AssemblyName>Mediator</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="Mediator.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> |
Design Patterns/Mediator/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Mediator | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Mediator Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + /// | ||
16 | + | ||
17 | + //Define an object that encapsulates how a set of objects interact. | ||
18 | + //Mediator promotes loose coupling by keeping objects from referring to each other explicitly, | ||
19 | + //and it lets you vary their interaction independently. | ||
20 | + | ||
21 | + class MainApp | ||
22 | + { | ||
23 | + /// <summary> | ||
24 | + | ||
25 | + /// Entry point into console application. | ||
26 | + | ||
27 | + /// </summary> | ||
28 | + | ||
29 | + static void Main() | ||
30 | + { | ||
31 | + ConcreteMediator m = new ConcreteMediator(); | ||
32 | + | ||
33 | + ConcreteColleague1 c1 = new ConcreteColleague1(m); | ||
34 | + ConcreteColleague2 c2 = new ConcreteColleague2(m); | ||
35 | + | ||
36 | + m.Colleague1 = c1; | ||
37 | + m.Colleague2 = c2; | ||
38 | + | ||
39 | + c1.Send("How are you?"); | ||
40 | + c2.Send("Fine, thanks"); | ||
41 | + | ||
42 | + // Wait for user | ||
43 | + | ||
44 | + Console.ReadKey(); | ||
45 | + } | ||
46 | + } | ||
47 | + | ||
48 | + /// <summary> | ||
49 | + | ||
50 | + /// The 'Mediator' abstract class | ||
51 | + | ||
52 | + /// </summary> | ||
53 | + | ||
54 | + abstract class Mediator | ||
55 | + { | ||
56 | + public abstract void Send(string message, | ||
57 | + Colleague colleague); | ||
58 | + } | ||
59 | + | ||
60 | + /// <summary> | ||
61 | + | ||
62 | + /// The 'ConcreteMediator' class | ||
63 | + | ||
64 | + /// </summary> | ||
65 | + | ||
66 | + class ConcreteMediator : Mediator | ||
67 | + { | ||
68 | + private ConcreteColleague1 _colleague1; | ||
69 | + private ConcreteColleague2 _colleague2; | ||
70 | + | ||
71 | + public ConcreteColleague1 Colleague1 | ||
72 | + { | ||
73 | + set { _colleague1 = value; } | ||
74 | + } | ||
75 | + | ||
76 | + public ConcreteColleague2 Colleague2 | ||
77 | + { | ||
78 | + set { _colleague2 = value; } | ||
79 | + } | ||
80 | + | ||
81 | + public override void Send(string message, | ||
82 | + Colleague colleague) | ||
83 | + { | ||
84 | + if (colleague == _colleague1) | ||
85 | + { | ||
86 | + _colleague2.Notify(message); | ||
87 | + } | ||
88 | + else | ||
89 | + { | ||
90 | + _colleague1.Notify(message); | ||
91 | + } | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /// <summary> | ||
96 | + | ||
97 | + /// The 'Colleague' abstract class | ||
98 | + | ||
99 | + /// </summary> | ||
100 | + | ||
101 | + abstract class Colleague | ||
102 | + { | ||
103 | + protected Mediator mediator; | ||
104 | + | ||
105 | + // Constructor | ||
106 | + | ||
107 | + public Colleague(Mediator mediator) | ||
108 | + { | ||
109 | + this.mediator = mediator; | ||
110 | + } | ||
111 | + } | ||
112 | + | ||
113 | + /// <summary> | ||
114 | + | ||
115 | + /// A 'ConcreteColleague' class | ||
116 | + | ||
117 | + /// </summary> | ||
118 | + | ||
119 | + class ConcreteColleague1 : Colleague | ||
120 | + { | ||
121 | + // Constructor | ||
122 | + | ||
123 | + public ConcreteColleague1(Mediator mediator) | ||
124 | + : base(mediator) | ||
125 | + { | ||
126 | + } | ||
127 | + | ||
128 | + public void Send(string message) | ||
129 | + { | ||
130 | + mediator.Send(message, this); | ||
131 | + } | ||
132 | + | ||
133 | + public void Notify(string message) | ||
134 | + { | ||
135 | + Console.WriteLine("Colleague1 gets message: " | ||
136 | + | ||
137 | + + message); | ||
138 | + } | ||
139 | + } | ||
140 | + | ||
141 | + /// <summary> | ||
142 | + | ||
143 | + /// A 'ConcreteColleague' class | ||
144 | + | ||
145 | + /// </summary> | ||
146 | + | ||
147 | + class ConcreteColleague2 : Colleague | ||
148 | + { | ||
149 | + // Constructor | ||
150 | + | ||
151 | + public ConcreteColleague2(Mediator mediator) | ||
152 | + : base(mediator) | ||
153 | + { | ||
154 | + } | ||
155 | + | ||
156 | + public void Send(string message) | ||
157 | + { | ||
158 | + mediator.Send(message, this); | ||
159 | + } | ||
160 | + | ||
161 | + public void Notify(string message) | ||
162 | + { | ||
163 | + Console.WriteLine("Colleague2 gets message: " | ||
164 | + | ||
165 | + + message); | ||
166 | + } | ||
167 | + } | ||
168 | +} |
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("Mediator")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Mediator")] | ||
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("64cd0017-ce57-4d16-9f18-baa534212117")] | ||
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 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Mediator\bin\Debug\Mediator.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Mediator\bin\Debug\Mediator.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Mediator\obj\x86\Debug\Mediator.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Mediator\obj\x86\Debug\Mediator.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Memento/Memento.PNG
0 → 100644
13 KB
Design Patterns/Memento/Memento.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>{922D79D0-8F3B-4C34-8E46-8DD24778F736}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Memento</RootNamespace> | ||
12 | + <AssemblyName>Memento</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="Memento.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> |
Design Patterns/Memento/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Memento | ||
7 | +{ | ||
8 | + class Program | ||
9 | + { | ||
10 | + | ||
11 | + /// <summary> | ||
12 | + | ||
13 | + /// MainApp startup class for Structural | ||
14 | + | ||
15 | + /// Memento Design Pattern. | ||
16 | + | ||
17 | + /// </summary> | ||
18 | + /// | ||
19 | + | ||
20 | + // Without violating encapsulation, capture and externalize an object's | ||
21 | + //internal state so that the object can be restored to this state later. | ||
22 | + | ||
23 | + | ||
24 | + class MainApp | ||
25 | + { | ||
26 | + /// <summary> | ||
27 | + | ||
28 | + /// Entry point into console application. | ||
29 | + | ||
30 | + /// </summary> | ||
31 | + | ||
32 | + static void Main() | ||
33 | + { | ||
34 | + Originator o = new Originator(); | ||
35 | + o.State = "On"; | ||
36 | + | ||
37 | + // Store internal state | ||
38 | + | ||
39 | + Caretaker c = new Caretaker(); | ||
40 | + c.Memento = o.CreateMemento(); | ||
41 | + | ||
42 | + // Continue changing originator | ||
43 | + | ||
44 | + o.State = "Off"; | ||
45 | + | ||
46 | + // Restore saved state | ||
47 | + | ||
48 | + o.SetMemento(c.Memento); | ||
49 | + | ||
50 | + // Wait for user | ||
51 | + | ||
52 | + Console.ReadKey(); | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + /// <summary> | ||
57 | + | ||
58 | + /// The 'Originator' class | ||
59 | + | ||
60 | + /// </summary> | ||
61 | + | ||
62 | + class Originator | ||
63 | + { | ||
64 | + private string _state; | ||
65 | + | ||
66 | + // Property | ||
67 | + | ||
68 | + public string State | ||
69 | + { | ||
70 | + get { return _state; } | ||
71 | + set | ||
72 | + { | ||
73 | + _state = value; | ||
74 | + Console.WriteLine("State = " + _state); | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
78 | + // Creates memento | ||
79 | + | ||
80 | + public Memento CreateMemento() | ||
81 | + { | ||
82 | + return (new Memento(_state)); | ||
83 | + } | ||
84 | + | ||
85 | + // Restores original state | ||
86 | + | ||
87 | + public void SetMemento(Memento memento) | ||
88 | + { | ||
89 | + Console.WriteLine("Restoring state..."); | ||
90 | + State = memento.State; | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + /// <summary> | ||
95 | + | ||
96 | + /// The 'Memento' class | ||
97 | + | ||
98 | + /// </summary> | ||
99 | + | ||
100 | + class Memento | ||
101 | + { | ||
102 | + private string _state; | ||
103 | + | ||
104 | + // Constructor | ||
105 | + | ||
106 | + public Memento(string state) | ||
107 | + { | ||
108 | + this._state = state; | ||
109 | + } | ||
110 | + | ||
111 | + // Gets or sets state | ||
112 | + | ||
113 | + public string State | ||
114 | + { | ||
115 | + get { return _state; } | ||
116 | + } | ||
117 | + } | ||
118 | + | ||
119 | + /// <summary> | ||
120 | + | ||
121 | + /// The 'Caretaker' class | ||
122 | + | ||
123 | + /// </summary> | ||
124 | + | ||
125 | + class Caretaker | ||
126 | + { | ||
127 | + private Memento _memento; | ||
128 | + | ||
129 | + // Gets or sets memento | ||
130 | + | ||
131 | + public Memento Memento | ||
132 | + { | ||
133 | + set { _memento = value; } | ||
134 | + get { return _memento; } | ||
135 | + } | ||
136 | + } | ||
137 | + } | ||
138 | +} | ||
139 | + |
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("Memento")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Memento")] | ||
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("e6d82812-cc9f-4810-a580-195e62251d15")] | ||
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 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Memento\bin\Debug\Memento.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Memento\bin\Debug\Memento.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Memento\obj\x86\Debug\Memento.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Memento\obj\x86\Debug\Memento.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Observer/Observer.PNG
0 → 100644
18.8 KB
Design Patterns/Observer/Observer.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>{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Observer</RootNamespace> | ||
12 | + <AssemblyName>Observer</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="Observer.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> |
Design Patterns/Observer/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Observer | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Observer Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + //Define a one-to-many dependency between objects so that when one object changes state, | ||
16 | + //all its dependents are notified and updated automatically. | ||
17 | + | ||
18 | + class MainApp | ||
19 | + { | ||
20 | + /// <summary> | ||
21 | + | ||
22 | + /// Entry point into console application. | ||
23 | + | ||
24 | + /// </summary> | ||
25 | + | ||
26 | + static void Main() | ||
27 | + { | ||
28 | + // Configure Observer pattern | ||
29 | + | ||
30 | + ConcreteSubject s = new ConcreteSubject(); | ||
31 | + | ||
32 | + s.Attach(new ConcreteObserver(s, "X")); | ||
33 | + s.Attach(new ConcreteObserver(s, "Y")); | ||
34 | + s.Attach(new ConcreteObserver(s, "Z")); | ||
35 | + | ||
36 | + // Change subject and notify observers | ||
37 | + | ||
38 | + s.SubjectState = "ABC"; | ||
39 | + s.Notify(); | ||
40 | + | ||
41 | + // Wait for user | ||
42 | + | ||
43 | + Console.ReadKey(); | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | + /// <summary> | ||
48 | + | ||
49 | + /// The 'Subject' abstract class | ||
50 | + | ||
51 | + /// </summary> | ||
52 | + | ||
53 | + abstract class Subject | ||
54 | + { | ||
55 | + private List<Observer> _observers = new List<Observer>(); | ||
56 | + | ||
57 | + public void Attach(Observer observer) | ||
58 | + { | ||
59 | + _observers.Add(observer); | ||
60 | + } | ||
61 | + | ||
62 | + public void Detach(Observer observer) | ||
63 | + { | ||
64 | + _observers.Remove(observer); | ||
65 | + } | ||
66 | + | ||
67 | + public void Notify() | ||
68 | + { | ||
69 | + foreach (Observer o in _observers) | ||
70 | + { | ||
71 | + o.Update(); | ||
72 | + } | ||
73 | + } | ||
74 | + } | ||
75 | + | ||
76 | + /// <summary> | ||
77 | + | ||
78 | + /// The 'ConcreteSubject' class | ||
79 | + | ||
80 | + /// </summary> | ||
81 | + | ||
82 | + class ConcreteSubject : Subject | ||
83 | + { | ||
84 | + private string _subjectState; | ||
85 | + | ||
86 | + // Gets or sets subject state | ||
87 | + | ||
88 | + public string SubjectState | ||
89 | + { | ||
90 | + get { return _subjectState; } | ||
91 | + set { _subjectState = value; } | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /// <summary> | ||
96 | + | ||
97 | + /// The 'Observer' abstract class | ||
98 | + | ||
99 | + /// </summary> | ||
100 | + | ||
101 | + abstract class Observer | ||
102 | + { | ||
103 | + public abstract void Update(); | ||
104 | + } | ||
105 | + | ||
106 | + /// <summary> | ||
107 | + | ||
108 | + /// The 'ConcreteObserver' class | ||
109 | + | ||
110 | + /// </summary> | ||
111 | + | ||
112 | + class ConcreteObserver : Observer | ||
113 | + { | ||
114 | + private string _name; | ||
115 | + private string _observerState; | ||
116 | + private ConcreteSubject _subject; | ||
117 | + | ||
118 | + // Constructor | ||
119 | + | ||
120 | + public ConcreteObserver( | ||
121 | + ConcreteSubject subject, string name) | ||
122 | + { | ||
123 | + this._subject = subject; | ||
124 | + this._name = name; | ||
125 | + } | ||
126 | + | ||
127 | + public override void Update() | ||
128 | + { | ||
129 | + _observerState = _subject.SubjectState; | ||
130 | + Console.WriteLine("Observer {0}'s new state is {1}", | ||
131 | + _name, _observerState); | ||
132 | + } | ||
133 | + | ||
134 | + // Gets or sets subject | ||
135 | + | ||
136 | + public ConcreteSubject Subject | ||
137 | + { | ||
138 | + get { return _subject; } | ||
139 | + set { _subject = value; } | ||
140 | + } | ||
141 | + } | ||
142 | +} |
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("Observer")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Observer")] | ||
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("097205f1-cb53-4455-a7a8-57470df5c620")] | ||
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 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Observer\bin\Debug\Observer.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Observer\bin\Debug\Observer.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Observer\obj\x86\Debug\Observer.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Observer\obj\x86\Debug\Observer.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Prototype/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Prototype | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Prototype 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 two instances and clone each | ||
27 | + | ||
28 | + | ||
29 | + ConcretePrototype1 p1 = new ConcretePrototype1("I"); | ||
30 | + ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone(); | ||
31 | + Console.WriteLine("Cloned: {0}", c1.Id); | ||
32 | + | ||
33 | + ConcretePrototype2 p2 = new ConcretePrototype2("II"); | ||
34 | + ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone(); | ||
35 | + Console.WriteLine("Cloned: {0}", c2.Id); | ||
36 | + | ||
37 | + // Wait for user | ||
38 | + | ||
39 | + Console.ReadKey(); | ||
40 | + } | ||
41 | + } | ||
42 | + | ||
43 | + /// <summary> | ||
44 | + | ||
45 | + /// The 'Prototype' abstract class | ||
46 | + | ||
47 | + /// </summary> | ||
48 | + | ||
49 | + abstract class Prototype | ||
50 | + { | ||
51 | + private string _id; | ||
52 | + | ||
53 | + // Constructor | ||
54 | + | ||
55 | + public Prototype(string id) | ||
56 | + { | ||
57 | + this._id = id; | ||
58 | + } | ||
59 | + | ||
60 | + // Gets id | ||
61 | + | ||
62 | + public string Id | ||
63 | + { | ||
64 | + get { return _id; } | ||
65 | + } | ||
66 | + | ||
67 | + public abstract Prototype Clone(); | ||
68 | + } | ||
69 | + | ||
70 | + /// <summary> | ||
71 | + | ||
72 | + /// A 'ConcretePrototype' class | ||
73 | + | ||
74 | + /// </summary> | ||
75 | + | ||
76 | + class ConcretePrototype1 : Prototype | ||
77 | + { | ||
78 | + // Constructor | ||
79 | + | ||
80 | + public ConcretePrototype1(string id) | ||
81 | + : base(id) | ||
82 | + { | ||
83 | + } | ||
84 | + | ||
85 | + // Returns a shallow copy | ||
86 | + | ||
87 | + public override Prototype Clone() | ||
88 | + { | ||
89 | + return (Prototype)this.MemberwiseClone(); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + /// <summary> | ||
94 | + | ||
95 | + /// A 'ConcretePrototype' class | ||
96 | + | ||
97 | + /// </summary> | ||
98 | + | ||
99 | + class ConcretePrototype2 : Prototype | ||
100 | + { | ||
101 | + // Constructor | ||
102 | + | ||
103 | + public ConcretePrototype2(string id) | ||
104 | + : base(id) | ||
105 | + { | ||
106 | + } | ||
107 | + | ||
108 | + // Returns a shallow copy | ||
109 | + | ||
110 | + public override Prototype Clone() | ||
111 | + { | ||
112 | + return (Prototype)this.MemberwiseClone(); | ||
113 | + } | ||
114 | + } | ||
115 | +} |
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("Prototype")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Prototype")] | ||
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("c5d8f9f7-a4e3-4156-9ab4-c63e1de6ff28")] | ||
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/Prototype/Prototype.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>{79BAA664-FC5B-4570-BC38-72DC6E4277CB}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Prototype</RootNamespace> | ||
12 | + <AssemblyName>Prototype</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> |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Prototype\bin\Debug\Prototype.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Prototype\bin\Debug\Prototype.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Prototype\obj\x86\Debug\Prototype.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Prototype\obj\x86\Debug\Prototype.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Proxy/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Proxy | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Proxy 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 proxy and request a service | ||
27 | + | ||
28 | + Proxy proxy = new Proxy(); | ||
29 | + proxy.Request(); | ||
30 | + | ||
31 | + // Wait for user | ||
32 | + | ||
33 | + Console.ReadKey(); | ||
34 | + } | ||
35 | + } | ||
36 | + | ||
37 | + /// <summary> | ||
38 | + | ||
39 | + /// The 'Subject' abstract class | ||
40 | + | ||
41 | + /// </summary> | ||
42 | + | ||
43 | + abstract class Subject | ||
44 | + { | ||
45 | + public abstract void Request(); | ||
46 | + } | ||
47 | + | ||
48 | + /// <summary> | ||
49 | + | ||
50 | + /// The 'RealSubject' class | ||
51 | + | ||
52 | + /// </summary> | ||
53 | + | ||
54 | + class RealSubject : Subject | ||
55 | + { | ||
56 | + public override void Request() | ||
57 | + { | ||
58 | + Console.WriteLine("Called RealSubject.Request()"); | ||
59 | + } | ||
60 | + } | ||
61 | + | ||
62 | + /// <summary> | ||
63 | + | ||
64 | + /// The 'Proxy' class | ||
65 | + | ||
66 | + /// </summary> | ||
67 | + | ||
68 | + class Proxy : Subject | ||
69 | + { | ||
70 | + private RealSubject _realSubject; | ||
71 | + | ||
72 | + public override void Request() | ||
73 | + { | ||
74 | + // Use 'lazy initialization' | ||
75 | + | ||
76 | + if (_realSubject == null) | ||
77 | + { | ||
78 | + _realSubject = new RealSubject(); | ||
79 | + } | ||
80 | + | ||
81 | + _realSubject.Request(); | ||
82 | + } | ||
83 | + } | ||
84 | +} |
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("Proxy")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Proxy")] | ||
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("db0871c3-9bc1-4da2-b238-6f6b758751db")] | ||
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/Proxy/Proxy.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>{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Proxy</RootNamespace> | ||
12 | + <AssemblyName>Proxy</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/Proxy/bin/Debug/Proxy.exe
0 → 100644
No preview for this file type
Design Patterns/Proxy/bin/Debug/Proxy.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\Proxy\bin\Debug\Proxy.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Proxy\bin\Debug\Proxy.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Proxy\obj\x86\Debug\Proxy.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Proxy\obj\x86\Debug\Proxy.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Singleton/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +//Ensure a class has only one instance and provide a global point of access to it. | ||
7 | + | ||
8 | +namespace Singleton | ||
9 | +{ | ||
10 | + /// <summary> | ||
11 | + | ||
12 | + /// MainApp startup class for Structural | ||
13 | + | ||
14 | + /// Singleton Design Pattern. | ||
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 | + // Constructor is protected -- cannot use new | ||
29 | + | ||
30 | + Singleton s1 = Singleton.Instance(); | ||
31 | + Singleton s2 = Singleton.Instance(); | ||
32 | + | ||
33 | + // Test for same instance | ||
34 | + | ||
35 | + if (s1 == s2) | ||
36 | + { | ||
37 | + Console.WriteLine("Objects are the same instance"); | ||
38 | + } | ||
39 | + | ||
40 | + // Wait for user | ||
41 | + | ||
42 | + Console.ReadKey(); | ||
43 | + } | ||
44 | + } | ||
45 | + | ||
46 | + /// <summary> | ||
47 | + | ||
48 | + /// The 'Singleton' class | ||
49 | + | ||
50 | + /// </summary> | ||
51 | + | ||
52 | + sealed class Singleton | ||
53 | + { | ||
54 | + private static Singleton _instance; | ||
55 | + private static readonly object padlock = new object(); | ||
56 | + | ||
57 | + // Constructor is 'private' | ||
58 | + | ||
59 | + private Singleton() | ||
60 | + { | ||
61 | + } | ||
62 | + | ||
63 | + public static Singleton Instance() | ||
64 | + { | ||
65 | + // Uses lazy initialization. | ||
66 | + | ||
67 | + // Note: this is thread safe. | ||
68 | + lock (padlock) | ||
69 | + { | ||
70 | + if (_instance == null) | ||
71 | + { | ||
72 | + _instance = new Singleton(); | ||
73 | + } | ||
74 | + } | ||
75 | + return _instance; | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | + | ||
80 | + public sealed class SingletonWithOutLock | ||
81 | + { | ||
82 | + private static readonly SingletonWithOutLock instance = new SingletonWithOutLock(); | ||
83 | + | ||
84 | + // Explicit static constructor to tell C# compiler | ||
85 | + // not to mark type as beforefieldinit | ||
86 | + static SingletonWithOutLock() | ||
87 | + { | ||
88 | + } | ||
89 | + | ||
90 | + private SingletonWithOutLock() | ||
91 | + { | ||
92 | + } | ||
93 | + | ||
94 | + public static SingletonWithOutLock Instance | ||
95 | + { | ||
96 | + get | ||
97 | + { | ||
98 | + return instance; | ||
99 | + } | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + public sealed class Singleton4Framework | ||
104 | + { | ||
105 | + private static readonly Lazy<Singleton4Framework> lazy = | ||
106 | + new Lazy<Singleton4Framework>(() => new Singleton4Framework()); | ||
107 | + | ||
108 | + public static Singleton4Framework Instance { get { return lazy.Value; } } | ||
109 | + | ||
110 | + private Singleton4Framework() | ||
111 | + { | ||
112 | + } | ||
113 | + } | ||
114 | +} | ||
115 | + |
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("Singleton")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Singleton")] | ||
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("49a4e46a-1b98-4687-9f62-d56bcd9c6897")] | ||
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/Singleton/Singleton.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>{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Singleton</RootNamespace> | ||
12 | + <AssemblyName>Singleton</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> |
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> |
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Singleton\bin\Debug\Singleton.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Singleton\bin\Debug\Singleton.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Singleton\obj\x86\Debug\Singleton.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Singleton\obj\x86\Debug\Singleton.pdb |
No preview for this file type
No preview for this file type
Design Patterns/State/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace State | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// State Design Pattern. | ||
13 | + /// Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. | ||
14 | + | ||
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 | + // Setup context in a state | ||
28 | + | ||
29 | + Context c = new Context(new ConcreteStateA()); | ||
30 | + | ||
31 | + // Issue requests, which toggles state | ||
32 | + | ||
33 | + c.Request(); | ||
34 | + c.Request(); | ||
35 | + c.Request(); | ||
36 | + c.Request(); | ||
37 | + | ||
38 | + // Wait for user | ||
39 | + | ||
40 | + Console.ReadKey(); | ||
41 | + } | ||
42 | + } | ||
43 | + | ||
44 | + /// <summary> | ||
45 | + | ||
46 | + /// The 'State' abstract class | ||
47 | + | ||
48 | + /// </summary> | ||
49 | + | ||
50 | + abstract class State | ||
51 | + { | ||
52 | + public abstract void Handle(Context context); | ||
53 | + } | ||
54 | + | ||
55 | + /// <summary> | ||
56 | + | ||
57 | + /// A 'ConcreteState' class | ||
58 | + | ||
59 | + /// </summary> | ||
60 | + | ||
61 | + class ConcreteStateA : State | ||
62 | + { | ||
63 | + public override void Handle(Context context) | ||
64 | + { | ||
65 | + context.State = new ConcreteStateB(); | ||
66 | + } | ||
67 | + } | ||
68 | + | ||
69 | + /// <summary> | ||
70 | + | ||
71 | + /// A 'ConcreteState' class | ||
72 | + | ||
73 | + /// </summary> | ||
74 | + | ||
75 | + class ConcreteStateB : State | ||
76 | + { | ||
77 | + public override void Handle(Context context) | ||
78 | + { | ||
79 | + context.State = new ConcreteStateA(); | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + /// <summary> | ||
84 | + | ||
85 | + /// The 'Context' class | ||
86 | + | ||
87 | + /// </summary> | ||
88 | + | ||
89 | + class Context | ||
90 | + { | ||
91 | + private State _state; | ||
92 | + | ||
93 | + // Constructor | ||
94 | + | ||
95 | + public Context(State state) | ||
96 | + { | ||
97 | + this.State = state; | ||
98 | + } | ||
99 | + | ||
100 | + // Gets or sets the state | ||
101 | + | ||
102 | + public State State | ||
103 | + { | ||
104 | + get { return _state; } | ||
105 | + set | ||
106 | + { | ||
107 | + _state = value; | ||
108 | + Console.WriteLine("State: " + | ||
109 | + _state.GetType().Name); | ||
110 | + } | ||
111 | + } | ||
112 | + | ||
113 | + public void Request() | ||
114 | + { | ||
115 | + _state.Handle(this); | ||
116 | + } | ||
117 | + } | ||
118 | +} |
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("State")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("State")] | ||
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("4014b485-b3e0-4710-b069-70efa69afb6a")] | ||
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/State/State.PNG
0 → 100644
10.8 KB
Design Patterns/State/State.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>{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>State</RootNamespace> | ||
12 | + <AssemblyName>State</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="State.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> |
Design Patterns/State/bin/Debug/State.exe
0 → 100644
No preview for this file type
Design Patterns/State/bin/Debug/State.pdb
0 → 100644
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\State\bin\Debug\State.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\State\bin\Debug\State.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\State\obj\x86\Debug\State.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\State\obj\x86\Debug\State.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Strategy/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Strategy | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Strategy Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + /// | ||
16 | + | ||
17 | + // Define a family of algorithms, | ||
18 | + //encapsulate each one, and make them interchangeable. | ||
19 | + //Strategy lets the algorithm vary independently from clients that use 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 | + Context context; | ||
32 | + | ||
33 | + // Three contexts following different strategies | ||
34 | + | ||
35 | + context = new Context(new ConcreteStrategyA()); | ||
36 | + context.ContextInterface(); | ||
37 | + | ||
38 | + context = new Context(new ConcreteStrategyB()); | ||
39 | + context.ContextInterface(); | ||
40 | + | ||
41 | + context = new Context(new ConcreteStrategyC()); | ||
42 | + context.ContextInterface(); | ||
43 | + | ||
44 | + // Wait for user | ||
45 | + | ||
46 | + Console.ReadKey(); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + /// <summary> | ||
51 | + | ||
52 | + /// The 'Strategy' abstract class | ||
53 | + | ||
54 | + /// </summary> | ||
55 | + | ||
56 | + abstract class Strategy | ||
57 | + { | ||
58 | + public abstract void AlgorithmInterface(); | ||
59 | + } | ||
60 | + | ||
61 | + /// <summary> | ||
62 | + | ||
63 | + /// A 'ConcreteStrategy' class | ||
64 | + | ||
65 | + /// </summary> | ||
66 | + | ||
67 | + class ConcreteStrategyA : Strategy | ||
68 | + { | ||
69 | + public override void AlgorithmInterface() | ||
70 | + { | ||
71 | + Console.WriteLine( | ||
72 | + "Called ConcreteStrategyA.AlgorithmInterface()"); | ||
73 | + } | ||
74 | + } | ||
75 | + | ||
76 | + /// <summary> | ||
77 | + | ||
78 | + /// A 'ConcreteStrategy' class | ||
79 | + | ||
80 | + /// </summary> | ||
81 | + | ||
82 | + class ConcreteStrategyB : Strategy | ||
83 | + { | ||
84 | + public override void AlgorithmInterface() | ||
85 | + { | ||
86 | + Console.WriteLine( | ||
87 | + "Called ConcreteStrategyB.AlgorithmInterface()"); | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + /// <summary> | ||
92 | + | ||
93 | + /// A 'ConcreteStrategy' class | ||
94 | + | ||
95 | + /// </summary> | ||
96 | + | ||
97 | + class ConcreteStrategyC : Strategy | ||
98 | + { | ||
99 | + public override void AlgorithmInterface() | ||
100 | + { | ||
101 | + Console.WriteLine( | ||
102 | + "Called ConcreteStrategyC.AlgorithmInterface()"); | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + /// <summary> | ||
107 | + | ||
108 | + /// The 'Context' class | ||
109 | + | ||
110 | + /// </summary> | ||
111 | + | ||
112 | + class Context | ||
113 | + { | ||
114 | + private Strategy _strategy; | ||
115 | + | ||
116 | + // Constructor | ||
117 | + | ||
118 | + public Context(Strategy strategy) | ||
119 | + { | ||
120 | + this._strategy = strategy; | ||
121 | + } | ||
122 | + | ||
123 | + public void ContextInterface() | ||
124 | + { | ||
125 | + _strategy.AlgorithmInterface(); | ||
126 | + } | ||
127 | + } | ||
128 | +} |
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("Strategy")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Strategy")] | ||
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("d7b10377-4831-42d8-b85a-4145c4bbeb54")] | ||
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/Strategy/Strategy.PNG
0 → 100644
11.4 KB
Design Patterns/Strategy/Strategy.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>{7AD5BC76-49BE-4700-85FA-DF869151B66C}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Strategy</RootNamespace> | ||
12 | + <AssemblyName>Strategy</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="Strategy.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> |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Strategy\bin\Debug\Strategy.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Strategy\bin\Debug\Strategy.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Strategy\obj\x86\Debug\Strategy.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Strategy\obj\x86\Debug\Strategy.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Template Method/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Template_Method | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Real-World | ||
11 | + | ||
12 | + /// Template Design Pattern. | ||
13 | + /// | ||
14 | + | ||
15 | +//Definition | ||
16 | +//Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. | ||
17 | +//Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure. | ||
18 | + | ||
19 | + /// </summary> | ||
20 | + | ||
21 | + class MainApp | ||
22 | + { | ||
23 | + /// <summary> | ||
24 | + | ||
25 | + /// Entry point into console application. | ||
26 | + | ||
27 | + /// </summary> | ||
28 | + | ||
29 | + static void Main() | ||
30 | + { | ||
31 | + AbstractClass aA = new ConcreteClassA(); | ||
32 | + aA.TemplateMethod(); | ||
33 | + | ||
34 | + AbstractClass aB = new ConcreteClassB(); | ||
35 | + aB.TemplateMethod(); | ||
36 | + | ||
37 | + // Wait for user | ||
38 | + | ||
39 | + Console.ReadKey(); | ||
40 | + } | ||
41 | + } | ||
42 | + | ||
43 | + /// <summary> | ||
44 | + | ||
45 | + /// The 'AbstractClass' abstract class | ||
46 | + | ||
47 | + /// </summary> | ||
48 | + | ||
49 | + abstract class AbstractClass | ||
50 | + { | ||
51 | + public abstract void PrimitiveOperation1(); | ||
52 | + public abstract void PrimitiveOperation2(); | ||
53 | + | ||
54 | + // The "Template method" | ||
55 | + | ||
56 | + public void TemplateMethod() | ||
57 | + { | ||
58 | + PrimitiveOperation1(); | ||
59 | + PrimitiveOperation2(); | ||
60 | + Console.WriteLine(""); | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + /// <summary> | ||
65 | + | ||
66 | + /// A 'ConcreteClass' class | ||
67 | + | ||
68 | + /// </summary> | ||
69 | + | ||
70 | + class ConcreteClassA : AbstractClass | ||
71 | + { | ||
72 | + public override void PrimitiveOperation1() | ||
73 | + { | ||
74 | + Console.WriteLine("ConcreteClassA.PrimitiveOperation1()"); | ||
75 | + } | ||
76 | + public override void PrimitiveOperation2() | ||
77 | + { | ||
78 | + Console.WriteLine("ConcreteClassA.PrimitiveOperation2()"); | ||
79 | + } | ||
80 | + } | ||
81 | + | ||
82 | + /// <summary> | ||
83 | + | ||
84 | + /// A 'ConcreteClass' class | ||
85 | + | ||
86 | + /// </summary> | ||
87 | + | ||
88 | + class ConcreteClassB : AbstractClass | ||
89 | + { | ||
90 | + public override void PrimitiveOperation1() | ||
91 | + { | ||
92 | + Console.WriteLine("ConcreteClassB.PrimitiveOperation1()"); | ||
93 | + } | ||
94 | + public override void PrimitiveOperation2() | ||
95 | + { | ||
96 | + Console.WriteLine("ConcreteClassB.PrimitiveOperation2()"); | ||
97 | + } | ||
98 | + } | ||
99 | +} |
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("Template Method")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Template Method")] | ||
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("69cc6696-b244-42f8-9db3-370dc45d003e")] | ||
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")] |
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>{2A8BF715-1168-428D-869F-485CB4DEB671}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Template_Method</RootNamespace> | ||
12 | + <AssemblyName>Template 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 | + <ItemGroup> | ||
50 | + <Content Include="Template.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> |
Design Patterns/Template Method/Template.PNG
0 → 100644
12.2 KB
No preview for this file type
No preview for this file type
Design Patterns/Template Method/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
0 → 100644
No preview for this file type
Design Patterns/Template Method/obj/x86/Debug/Template Method.csproj.FileListAbsolute.txt
0 → 100644
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Template Method\bin\Debug\Template Method.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Template Method\bin\Debug\Template Method.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Template Method\obj\x86\Debug\Template Method.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Template Method\obj\x86\Debug\Template Method.pdb |
No preview for this file type
No preview for this file type
Design Patterns/Visitor/Program.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Text; | ||
5 | + | ||
6 | +namespace Visitor | ||
7 | +{ | ||
8 | + /// <summary> | ||
9 | + | ||
10 | + /// MainApp startup class for Structural | ||
11 | + | ||
12 | + /// Visitor Design Pattern. | ||
13 | + | ||
14 | + /// </summary> | ||
15 | + | ||
16 | + class MainApp | ||
17 | + { | ||
18 | + static void Main() | ||
19 | + { | ||
20 | + // Setup structure | ||
21 | + | ||
22 | + ObjectStructure o = new ObjectStructure(); | ||
23 | + o.Attach(new ConcreteElementA()); | ||
24 | + o.Attach(new ConcreteElementB()); | ||
25 | + | ||
26 | + // Create visitor objects | ||
27 | + | ||
28 | + ConcreteVisitor1 v1 = new ConcreteVisitor1(); | ||
29 | + ConcreteVisitor2 v2 = new ConcreteVisitor2(); | ||
30 | + | ||
31 | + // Structure accepting visitors | ||
32 | + | ||
33 | + o.Accept(v1); | ||
34 | + o.Accept(v2); | ||
35 | + | ||
36 | + // Wait for user | ||
37 | + | ||
38 | + Console.ReadKey(); | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + /// <summary> | ||
43 | + | ||
44 | + /// The 'Visitor' abstract class | ||
45 | + | ||
46 | + /// </summary> | ||
47 | + | ||
48 | + abstract class Visitor | ||
49 | + { | ||
50 | + public abstract void VisitConcreteElementA( | ||
51 | + ConcreteElementA concreteElementA); | ||
52 | + public abstract void VisitConcreteElementB( | ||
53 | + ConcreteElementB concreteElementB); | ||
54 | + } | ||
55 | + | ||
56 | + /// <summary> | ||
57 | + | ||
58 | + /// A 'ConcreteVisitor' class | ||
59 | + | ||
60 | + /// </summary> | ||
61 | + | ||
62 | + class ConcreteVisitor1 : Visitor | ||
63 | + { | ||
64 | + public override void VisitConcreteElementA( | ||
65 | + ConcreteElementA concreteElementA) | ||
66 | + { | ||
67 | + Console.WriteLine("{0} visited by {1}", | ||
68 | + concreteElementA.GetType().Name, this.GetType().Name); | ||
69 | + } | ||
70 | + | ||
71 | + public override void VisitConcreteElementB( | ||
72 | + ConcreteElementB concreteElementB) | ||
73 | + { | ||
74 | + Console.WriteLine("{0} visited by {1}", | ||
75 | + concreteElementB.GetType().Name, this.GetType().Name); | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | + /// <summary> | ||
80 | + | ||
81 | + /// A 'ConcreteVisitor' class | ||
82 | + | ||
83 | + /// </summary> | ||
84 | + | ||
85 | + class ConcreteVisitor2 : Visitor | ||
86 | + { | ||
87 | + public override void VisitConcreteElementA( | ||
88 | + ConcreteElementA concreteElementA) | ||
89 | + { | ||
90 | + Console.WriteLine("{0} visited by {1}", | ||
91 | + concreteElementA.GetType().Name, this.GetType().Name); | ||
92 | + } | ||
93 | + | ||
94 | + public override void VisitConcreteElementB( | ||
95 | + ConcreteElementB concreteElementB) | ||
96 | + { | ||
97 | + Console.WriteLine("{0} visited by {1}", | ||
98 | + concreteElementB.GetType().Name, this.GetType().Name); | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | + /// <summary> | ||
103 | + | ||
104 | + /// The 'Element' abstract class | ||
105 | + | ||
106 | + /// </summary> | ||
107 | + | ||
108 | + abstract class Element | ||
109 | + { | ||
110 | + public abstract void Accept(Visitor visitor); | ||
111 | + } | ||
112 | + | ||
113 | + /// <summary> | ||
114 | + | ||
115 | + /// A 'ConcreteElement' class | ||
116 | + | ||
117 | + /// </summary> | ||
118 | + | ||
119 | + class ConcreteElementA : Element | ||
120 | + { | ||
121 | + public override void Accept(Visitor visitor) | ||
122 | + { | ||
123 | + visitor.VisitConcreteElementA(this); | ||
124 | + } | ||
125 | + | ||
126 | + public void OperationA() | ||
127 | + { | ||
128 | + } | ||
129 | + } | ||
130 | + | ||
131 | + /// <summary> | ||
132 | + | ||
133 | + /// A 'ConcreteElement' class | ||
134 | + | ||
135 | + /// </summary> | ||
136 | + | ||
137 | + class ConcreteElementB : Element | ||
138 | + { | ||
139 | + public override void Accept(Visitor visitor) | ||
140 | + { | ||
141 | + visitor.VisitConcreteElementB(this); | ||
142 | + } | ||
143 | + | ||
144 | + public void OperationB() | ||
145 | + { | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + /// <summary> | ||
150 | + | ||
151 | + /// The 'ObjectStructure' class | ||
152 | + | ||
153 | + /// </summary> | ||
154 | + | ||
155 | + class ObjectStructure | ||
156 | + { | ||
157 | + private List<Element> _elements = new List<Element>(); | ||
158 | + | ||
159 | + public void Attach(Element element) | ||
160 | + { | ||
161 | + _elements.Add(element); | ||
162 | + } | ||
163 | + | ||
164 | + public void Detach(Element element) | ||
165 | + { | ||
166 | + _elements.Remove(element); | ||
167 | + } | ||
168 | + | ||
169 | + public void Accept(Visitor visitor) | ||
170 | + { | ||
171 | + foreach (Element element in _elements) | ||
172 | + { | ||
173 | + element.Accept(visitor); | ||
174 | + } | ||
175 | + } | ||
176 | + } | ||
177 | +} |
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("Visitor")] | ||
9 | +[assembly: AssemblyDescription("")] | ||
10 | +[assembly: AssemblyConfiguration("")] | ||
11 | +[assembly: AssemblyCompany("Microsoft")] | ||
12 | +[assembly: AssemblyProduct("Visitor")] | ||
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("b6146c39-1339-4ef5-82c9-e03f45abd1ad")] | ||
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/Visitor/Visitor.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>{148422F3-1363-4839-8D27-FD9CE37A9641}</ProjectGuid> | ||
9 | + <OutputType>Exe</OutputType> | ||
10 | + <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | + <RootNamespace>Visitor</RootNamespace> | ||
12 | + <AssemblyName>Visitor</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> |
No preview for this file type
No preview for this file type
No preview for this file type
1 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Visitor\bin\Debug\Visitor.exe | ||
2 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Visitor\bin\Debug\Visitor.pdb | ||
3 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Visitor\obj\x86\Debug\Visitor.exe | ||
4 | +c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Visitor\obj\x86\Debug\Visitor.pdb |
No preview for this file type
No preview for this file type
README.md
deleted
100644 → 0
-
Please register or login to post a comment