Authored by Rajesh Rai

Commiting the Design Pattern Project

Showing 100 changed files with 2516 additions and 0 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Abstract_Factory</RootNamespace>
<AssemblyName>Abstract Factory</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
namespace Abstract_Factory
{
/// <summary>
/// MainApp startup class for Structural
/// Abstract Factory Design Pattern.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
public static void Main()
{
// Abstract factory #1
AbstractFactory factory1 = new ConcreteFactory1();
Client client1 = new Client(factory1);
client1.Run();
// Abstract factory #2
AbstractFactory factory2 = new ConcreteFactory2();
Client client2 = new Client(factory2);
client2.Run();
// Wait for user input
Console.ReadKey();
}
}
/// <summary>
/// The 'AbstractFactory' abstract class
/// </summary>
abstract class AbstractFactory
{
public abstract AbstractProductA CreateProductA();
public abstract AbstractProductB CreateProductB();
}
/// <summary>
/// The 'ConcreteFactory1' class
/// </summary>
class ConcreteFactory1 : AbstractFactory
{
public override AbstractProductA CreateProductA()
{
return new ProductA1();
}
public override AbstractProductB CreateProductB()
{
return new ProductB1();
}
}
/// <summary>
/// The 'ConcreteFactory2' class
/// </summary>
class ConcreteFactory2 : AbstractFactory
{
public override AbstractProductA CreateProductA()
{
return new ProductA2();
}
public override AbstractProductB CreateProductB()
{
return new ProductB2();
}
}
/// <summary>
/// The 'AbstractProductA' abstract class
/// </summary>
abstract class AbstractProductA
{
}
/// <summary>
/// The 'AbstractProductB' abstract class
/// </summary>
abstract class AbstractProductB
{
public abstract void Interact(AbstractProductA a);
}
/// <summary>
/// The 'ProductA1' class
/// </summary>
class ProductA1 : AbstractProductA
{
}
/// <summary>
/// The 'ProductB1' class
/// </summary>
class ProductB1 : AbstractProductB
{
public override void Interact(AbstractProductA a)
{
Console.WriteLine(this.GetType().Name +
" interacts with " + a.GetType().Name);
}
}
/// <summary>
/// The 'ProductA2' class
/// </summary>
class ProductA2 : AbstractProductA
{
}
/// <summary>
/// The 'ProductB2' class
/// </summary>
class ProductB2 : AbstractProductB
{
public override void Interact(AbstractProductA a)
{
Console.WriteLine(this.GetType().Name +
" interacts with " + a.GetType().Name);
}
}
/// <summary>
/// The 'Client' class. Interaction environment for the products.
/// </summary>
class Client
{
private AbstractProductA _abstractProductA;
private AbstractProductB _abstractProductB;
// Constructor
public Client(AbstractFactory factory)
{
_abstractProductB = factory.CreateProductB();
_abstractProductA = factory.CreateProductA();
}
public void Run()
{
_abstractProductB.Interact(_abstractProductA);
}
}
}
\ No newline at end of file
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Abstract Factory")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Abstract Factory")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d0da81c5-80b1-4ed5-80ea-58dc3dc4d9d4")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\bin\Debug\Abstract Factory.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\bin\Debug\Abstract Factory.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\obj\x86\Debug\Abstract Factory.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Abstract Factory\obj\x86\Debug\Abstract Factory.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0267B2D7-39C6-4C11-90FF-540527EF457A}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Adapter</RootNamespace>
<AssemblyName>Adapter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Adapter.GIF" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adapter
{
/// <summary>
/// MainApp startup class for Structural
/// Adapter Design Pattern.
//Convert the interface of a class into another interface clients expect.
//Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
// Create adapter and place a request
Target target = new Adapter();
target.Request();
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Target' class
/// </summary>
class Target
{
public virtual void Request()
{
Console.WriteLine("Called Target Request()");
}
}
/// <summary>
/// The 'Adapter' class
/// </summary>
class Adapter : Target
{
private Adaptee _adaptee = new Adaptee();
public override void Request()
{
// Possibly do some other work
// and then call SpecificRequest
_adaptee.SpecificRequest();
}
}
/// <summary>
/// The 'Adaptee' class
/// </summary>
class Adaptee
{
public void SpecificRequest()
{
Console.WriteLine("Called SpecificRequest()");
}
}
}
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Adapter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Adapter")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1842066e-4be3-412f-8b8d-f2a4fb726f79")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
No preview for this file type
No preview for this file type
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\bin\Debug\Adapter.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\bin\Debug\Adapter.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\obj\x86\Debug\Adapter.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Adapter\obj\x86\Debug\Adapter.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B5700B60-C82F-4765-9695-CE0B43BCA5D7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Bridge</RootNamespace>
<AssemblyName>Bridge</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Bridge.GIF" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Bridge
{
/// <summary>
/// MainApp startup class for Structural
/// Bridge Design Pattern.
/// </summary>
//Decouple an abstraction from its implementation so that the two can vary independently.
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
Abstraction ab = new RefinedAbstraction();
// Set implementation and call
ab.Implementor = new ConcreteImplementorA();
ab.Operation();
// Change implemention and call
ab.Implementor = new ConcreteImplementorB();
ab.Operation();
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Abstraction' class
/// </summary>
class Abstraction
{
protected Implementor implementor;
// Property
public Implementor Implementor
{
set { implementor = value; }
}
public virtual void Operation()
{
implementor.Operation();
}
}
/// <summary>
/// The 'Implementor' abstract class
/// </summary>
abstract class Implementor
{
public abstract void Operation();
}
/// <summary>
/// The 'RefinedAbstraction' class
/// </summary>
class RefinedAbstraction : Abstraction
{
public override void Operation()
{
implementor.Operation();
}
}
/// <summary>
/// The 'ConcreteImplementorA' class
/// </summary>
class ConcreteImplementorA : Implementor
{
public override void Operation()
{
Console.WriteLine("ConcreteImplementorA Operation");
}
}
/// <summary>
/// The 'ConcreteImplementorB' class
/// </summary>
class ConcreteImplementorB : Implementor
{
public override void Operation()
{
Console.WriteLine("ConcreteImplementorB Operation");
}
}
}
\ No newline at end of file
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Bridge")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Bridge")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ad735d41-ed7a-4ef9-9592-60256f4b3634")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
No preview for this file type
No preview for this file type
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\bin\Debug\Bridge.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\bin\Debug\Bridge.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\obj\x86\Debug\Bridge.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Bridge\obj\x86\Debug\Bridge.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{50C2CC17-B3BC-4DB3-8901-24D18B757C23}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Builder</RootNamespace>
<AssemblyName>Builder</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Builder
{
using System;
using System.Collections.Generic;
namespace DoFactory.GangOfFour.Builder.Structural
{
/// <summary>
/// MainApp startup class for Structural
/// Builder Design Pattern.
/// </summary>
public class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
public static void Main()
{
// Create director and builders
Director director = new Director();
Builder b1 = new ConcreteBuilder1();
Builder b2 = new ConcreteBuilder2();
// Construct two products
director.Construct(b1);
Product p1 = b1.GetResult();
p1.Show();
director.Construct(b2);
Product p2 = b2.GetResult();
p2.Show();
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Director' class
/// </summary>
class Director
{
// Builder uses a complex series of steps
public void Construct(Builder builder)
{
builder.BuildPartA();
builder.BuildPartB();
}
}
/// <summary>
/// The 'Builder' abstract class
/// </summary>
abstract class Builder
{
public abstract void BuildPartA();
public abstract void BuildPartB();
public abstract Product GetResult();
}
/// <summary>
/// The 'ConcreteBuilder1' class
/// </summary>
class ConcreteBuilder1 : Builder
{
private Product _product = new Product();
public override void BuildPartA()
{
_product.Add("PartA");
}
public override void BuildPartB()
{
_product.Add("PartB");
}
public override Product GetResult()
{
return _product;
}
}
/// <summary>
/// The 'ConcreteBuilder2' class
/// </summary>
class ConcreteBuilder2 : Builder
{
private Product _product = new Product();
public override void BuildPartA()
{
_product.Add("PartX");
}
public override void BuildPartB()
{
_product.Add("PartY");
}
public override Product GetResult()
{
return _product;
}
}
/// <summary>
/// The 'Product' class
/// </summary>
class Product
{
private List<string> _parts = new List<string>();
public void Add(string part)
{
_parts.Add(part);
}
public void Show()
{
Console.WriteLine("\nProduct Parts -------");
foreach (string part in _parts)
Console.WriteLine(part);
}
}
}
}
\ No newline at end of file
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Builder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Builder")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("eccc81ee-aafa-4853-b7cd-8fcdb3909ba0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
No preview for this file type
No preview for this file type
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\bin\Debug\Builder.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\bin\Debug\Builder.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\obj\x86\Debug\Builder.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Builder\obj\x86\Debug\Builder.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1FDCC993-010F-4E94-BA56-EF52EB9D8397}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Chain_of_Responsibility</RootNamespace>
<AssemblyName>Chain of Responsibility</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Chain_Of_Responsibility.PNG" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Chain_of_Responsibility
{
/// <summary>
/// MainApp startup class for Structural
/// Chain of Responsibility Design Pattern.
/// </summary>
///
//Definition
//Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.
//Chain the receiving objects and pass the request along the chain until an object handles it.
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
// Setup Chain of Responsibility
Handler h1 = new ConcreteHandler1();
Handler h2 = new ConcreteHandler2();
Handler h3 = new ConcreteHandler3();
h1.SetSuccessor(h2);
h2.SetSuccessor(h3);
// Generate and process request
int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 };
foreach (int request in requests)
{
h1.HandleRequest(request);
}
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Handler' abstract class
/// </summary>
abstract class Handler
{
protected Handler successor;
public void SetSuccessor(Handler successor)
{
this.successor = successor;
}
public abstract void HandleRequest(int request);
}
/// <summary>
/// The 'ConcreteHandler1' class
/// </summary>
class ConcreteHandler1 : Handler
{
public override void HandleRequest(int request)
{
if (request >= 0 && request < 10)
{
Console.WriteLine("{0} handled request {1}",
this.GetType().Name, request);
}
else if (successor != null)
{
successor.HandleRequest(request);
}
}
}
/// <summary>
/// The 'ConcreteHandler2' class
/// </summary>
class ConcreteHandler2 : Handler
{
public override void HandleRequest(int request)
{
if (request >= 10 && request < 20)
{
Console.WriteLine("{0} handled request {1}",
this.GetType().Name, request);
}
else if (successor != null)
{
successor.HandleRequest(request);
}
}
}
/// <summary>
/// The 'ConcreteHandler3' class
/// </summary>
class ConcreteHandler3 : Handler
{
public override void HandleRequest(int request)
{
if (request >= 20 && request < 30)
{
Console.WriteLine("{0} handled request {1}",
this.GetType().Name, request);
}
else if (successor != null)
{
successor.HandleRequest(request);
}
}
}
}
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Chain of Responsibility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Chain of Responsibility")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("72ec58d3-0328-4bcc-b410-dc6a00ff8730")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\bin\Debug\Chain of Responsibility.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\bin\Debug\Chain of Responsibility.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\obj\x86\Debug\Chain of Responsibility.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Chain of Responsibility\obj\x86\Debug\Chain of Responsibility.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Command</RootNamespace>
<AssemblyName>Command</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Command.GIF" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Command
{
/// <summary>
/// MainApp startup class for Structural
/// Command Design Pattern.
/// Encapsulate a request as an object, thereby letting you parameterize clients with different requests,
/// queue or log requests, and support undoable operations.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
// Create receiver, command, and invoker
Receiver receiver = new Receiver();
Command command = new ConcreteCommand(receiver);
Invoker invoker = new Invoker();
// Set and execute command
invoker.SetCommand(command);
invoker.ExecuteCommand();
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Command' abstract class
/// </summary>
abstract class Command
{
protected Receiver receiver;
// Constructor
public Command(Receiver receiver)
{
this.receiver = receiver;
}
public abstract void Execute();
}
/// <summary>
/// The 'ConcreteCommand' class
/// </summary>
class ConcreteCommand : Command
{
// Constructor
public ConcreteCommand(Receiver receiver) :
base(receiver)
{
}
public override void Execute()
{
receiver.Action();
}
}
/// <summary>
/// The 'Receiver' class
/// </summary>
class Receiver
{
public void Action()
{
Console.WriteLine("Called Receiver.Action()");
}
}
/// <summary>
/// The 'Invoker' class
/// </summary>
class Invoker
{
private Command _command;
public void SetCommand(Command command)
{
this._command = command;
}
public void ExecuteCommand()
{
_command.Execute();
}
}
}
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Command")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Command")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f3ceae8f-5101-46b3-9a96-2446e271892f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
No preview for this file type
No preview for this file type
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\bin\Debug\Command.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\bin\Debug\Command.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\obj\x86\Debug\Command.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Command\obj\x86\Debug\Command.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Composite</RootNamespace>
<AssemblyName>Composite</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Composite
{
/// <summary>
/// MainApp startup class for Structural
/// Composite Design Pattern.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
// Create a tree structure
Composite root = new Composite("root");
root.Add(new Leaf("Leaf A"));
root.Add(new Leaf("Leaf B"));
Composite comp = new Composite("Composite X");
comp.Add(new Leaf("Leaf XA"));
comp.Add(new Leaf("Leaf XB"));
root.Add(comp);
root.Add(new Leaf("Leaf C"));
// Add and remove a leaf
Leaf leaf = new Leaf("Leaf D");
root.Add(leaf);
root.Remove(leaf);
// Recursively display tree
root.Display(1);
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Component' abstract class
/// </summary>
abstract class Component
{
protected string name;
// Constructor
public Component(string name)
{
this.name = name;
}
public abstract void Add(Component c);
public abstract void Remove(Component c);
public abstract void Display(int depth);
}
/// <summary>
/// The 'Composite' class
/// </summary>
class Composite : Component
{
private List<Component> _children = new List<Component>();
// Constructor
public Composite(string name)
: base(name)
{
}
public override void Add(Component component)
{
_children.Add(component);
}
public override void Remove(Component component)
{
_children.Remove(component);
}
public override void Display(int depth)
{
Console.WriteLine(new String('-', depth) + name);
// Recursively display child nodes
foreach (Component component in _children)
{
component.Display(depth + 2);
}
}
}
/// <summary>
/// The 'Leaf' class
/// </summary>
class Leaf : Component
{
// Constructor
public Leaf(string name)
: base(name)
{
}
public override void Add(Component c)
{
Console.WriteLine("Cannot add to a leaf");
}
public override void Remove(Component c)
{
Console.WriteLine("Cannot remove from a leaf");
}
public override void Display(int depth)
{
Console.WriteLine(new String('-', depth) + name);
}
}
}
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Composite")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Composite")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a5af7192-8c50-4a4c-9dc9-0d530650e677")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\bin\Debug\Composite.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\bin\Debug\Composite.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\obj\x86\Debug\Composite.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Composite\obj\x86\Debug\Composite.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Decorator</RootNamespace>
<AssemblyName>Decorator</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Decorator
{
/// <summary>
/// MainApp startup class for Structural
/// Decorator Design Pattern.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
// Create ConcreteComponent and two Decorators
ConcreteComponent c = new ConcreteComponent();
ConcreteDecoratorA d1 = new ConcreteDecoratorA();
ConcreteDecoratorB d2 = new ConcreteDecoratorB();
// Link decorators
d1.SetComponent(c);
d2.SetComponent(d1);
d2.Operation();
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Component' abstract class
/// </summary>
abstract class Component
{
public abstract void Operation();
}
/// <summary>
/// The 'ConcreteComponent' class
/// </summary>
class ConcreteComponent : Component
{
public override void Operation()
{
Console.WriteLine("ConcreteComponent.Operation()");
}
}
/// <summary>
/// The 'Decorator' abstract class
/// </summary>
abstract class Decorator : Component
{
protected Component component;
public void SetComponent(Component component)
{
this.component = component;
}
public override void Operation()
{
if (component != null)
{
component.Operation();
}
}
}
/// <summary>
/// The 'ConcreteDecoratorA' class
/// </summary>
class ConcreteDecoratorA : Decorator
{
public override void Operation()
{
base.Operation();
Console.WriteLine("ConcreteDecoratorA.Operation()");
}
}
/// <summary>
/// The 'ConcreteDecoratorB' class
/// </summary>
class ConcreteDecoratorB : Decorator
{
public override void Operation()
{
base.Operation();
AddedBehavior();
Console.WriteLine("ConcreteDecoratorB.Operation()");
}
void AddedBehavior()
{
}
}
}
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Decorator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Decorator")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5274830d-b555-4ec3-872e-c97979c3dac2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\bin\Debug\Decorator.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\bin\Debug\Decorator.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\obj\x86\Debug\Decorator.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Decorator\obj\x86\Debug\Decorator.pdb
... ...

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abstract Factory", "Abstract Factory\Abstract Factory.csproj", "{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{50C2CC17-B3BC-4DB3-8901-24D18B757C23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Factory Method", "Factory Method\Factory Method.csproj", "{E332E255-A604-4C4C-A08C-2D6C9295C5D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prototype.csproj", "{79BAA664-FC5B-4570-BC38-72DC6E4277CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Singleton\Singleton.csproj", "{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{0267B2D7-39C6-4C11-90FF-540527EF457A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bridge", "Bridge\Bridge.csproj", "{B5700B60-C82F-4765-9695-CE0B43BCA5D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "Composite\Composite.csproj", "{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decorator", "Decorator\Decorator.csproj", "{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facade", "Facade\Facade.csproj", "{0C8C49C6-9121-49CC-9012-A1A627C2E960}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flyweight", "Flyweight\Flyweight.csproj", "{66E86937-D762-4BF4-A0D6-317E9F76D3E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proxy", "Proxy\Proxy.csproj", "{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chain of Responsibility", "Chain of Responsibility\Chain of Responsibility.csproj", "{1FDCC993-010F-4E94-BA56-EF52EB9D8397}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Command", "Command\Command.csproj", "{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interpreter", "Interpreter\Interpreter.csproj", "{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iterator", "Iterator\Iterator.csproj", "{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mediator", "Mediator\Mediator.csproj", "{26D2883D-0BFD-4D94-AF1E-12C4FD508478}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Memento", "Memento\Memento.csproj", "{922D79D0-8F3B-4C34-8E46-8DD24778F736}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Observer", "Observer\Observer.csproj", "{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "State", "State\State.csproj", "{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strategy", "Strategy\Strategy.csproj", "{7AD5BC76-49BE-4700-85FA-DF869151B66C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Template Method", "Template Method\Template Method.csproj", "{2A8BF715-1168-428D-869F-485CB4DEB671}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Visitor", "Visitor\Visitor.csproj", "{148422F3-1363-4839-8D27-FD9CE37A9641}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Creational Patterns", "Creational Patterns", "{1F110E75-AF31-4330-9090-89279E0814E0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Structural Patterns", "Structural Patterns", "{28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Behavioral Patterns", "Behavioral Patterns", "{DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Debug|x86.ActiveCfg = Debug|x86
{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Debug|x86.Build.0 = Debug|x86
{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Release|x86.ActiveCfg = Release|x86
{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0}.Release|x86.Build.0 = Release|x86
{50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Debug|x86.ActiveCfg = Debug|x86
{50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Debug|x86.Build.0 = Debug|x86
{50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Release|x86.ActiveCfg = Release|x86
{50C2CC17-B3BC-4DB3-8901-24D18B757C23}.Release|x86.Build.0 = Release|x86
{E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Debug|x86.ActiveCfg = Debug|x86
{E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Debug|x86.Build.0 = Debug|x86
{E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Release|x86.ActiveCfg = Release|x86
{E332E255-A604-4C4C-A08C-2D6C9295C5D2}.Release|x86.Build.0 = Release|x86
{79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Debug|x86.ActiveCfg = Debug|x86
{79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Debug|x86.Build.0 = Debug|x86
{79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Release|x86.ActiveCfg = Release|x86
{79BAA664-FC5B-4570-BC38-72DC6E4277CB}.Release|x86.Build.0 = Release|x86
{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Debug|x86.ActiveCfg = Debug|x86
{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Debug|x86.Build.0 = Debug|x86
{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Release|x86.ActiveCfg = Release|x86
{0F6A0D37-4735-474E-B027-8F8B9E52CC5A}.Release|x86.Build.0 = Release|x86
{0267B2D7-39C6-4C11-90FF-540527EF457A}.Debug|x86.ActiveCfg = Debug|x86
{0267B2D7-39C6-4C11-90FF-540527EF457A}.Debug|x86.Build.0 = Debug|x86
{0267B2D7-39C6-4C11-90FF-540527EF457A}.Release|x86.ActiveCfg = Release|x86
{0267B2D7-39C6-4C11-90FF-540527EF457A}.Release|x86.Build.0 = Release|x86
{B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Debug|x86.ActiveCfg = Debug|x86
{B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Debug|x86.Build.0 = Debug|x86
{B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Release|x86.ActiveCfg = Release|x86
{B5700B60-C82F-4765-9695-CE0B43BCA5D7}.Release|x86.Build.0 = Release|x86
{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Debug|x86.ActiveCfg = Debug|x86
{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Debug|x86.Build.0 = Debug|x86
{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Release|x86.ActiveCfg = Release|x86
{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7}.Release|x86.Build.0 = Release|x86
{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Debug|x86.ActiveCfg = Debug|x86
{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Debug|x86.Build.0 = Debug|x86
{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Release|x86.ActiveCfg = Release|x86
{10D7BF70-5C45-4A22-8BC3-FEFA6B122756}.Release|x86.Build.0 = Release|x86
{0C8C49C6-9121-49CC-9012-A1A627C2E960}.Debug|x86.ActiveCfg = Debug|x86
{0C8C49C6-9121-49CC-9012-A1A627C2E960}.Debug|x86.Build.0 = Debug|x86
{0C8C49C6-9121-49CC-9012-A1A627C2E960}.Release|x86.ActiveCfg = Release|x86
{0C8C49C6-9121-49CC-9012-A1A627C2E960}.Release|x86.Build.0 = Release|x86
{66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Debug|x86.ActiveCfg = Debug|x86
{66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Debug|x86.Build.0 = Debug|x86
{66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Release|x86.ActiveCfg = Release|x86
{66E86937-D762-4BF4-A0D6-317E9F76D3E8}.Release|x86.Build.0 = Release|x86
{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Debug|x86.ActiveCfg = Debug|x86
{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Debug|x86.Build.0 = Debug|x86
{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Release|x86.ActiveCfg = Release|x86
{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C}.Release|x86.Build.0 = Release|x86
{1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Debug|x86.ActiveCfg = Debug|x86
{1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Debug|x86.Build.0 = Debug|x86
{1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Release|x86.ActiveCfg = Release|x86
{1FDCC993-010F-4E94-BA56-EF52EB9D8397}.Release|x86.Build.0 = Release|x86
{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Debug|x86.ActiveCfg = Debug|x86
{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Debug|x86.Build.0 = Debug|x86
{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Release|x86.ActiveCfg = Release|x86
{554DD1E6-AF06-43D6-8736-9A6CBB8379A8}.Release|x86.Build.0 = Release|x86
{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Debug|x86.ActiveCfg = Debug|x86
{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Debug|x86.Build.0 = Debug|x86
{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Release|x86.ActiveCfg = Release|x86
{2356D5AD-BF8E-4B84-B929-DBD245AC38CF}.Release|x86.Build.0 = Release|x86
{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Debug|x86.ActiveCfg = Debug|x86
{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Debug|x86.Build.0 = Debug|x86
{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Release|x86.ActiveCfg = Release|x86
{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C}.Release|x86.Build.0 = Release|x86
{26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Debug|x86.ActiveCfg = Debug|x86
{26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Debug|x86.Build.0 = Debug|x86
{26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Release|x86.ActiveCfg = Release|x86
{26D2883D-0BFD-4D94-AF1E-12C4FD508478}.Release|x86.Build.0 = Release|x86
{922D79D0-8F3B-4C34-8E46-8DD24778F736}.Debug|x86.ActiveCfg = Debug|x86
{922D79D0-8F3B-4C34-8E46-8DD24778F736}.Debug|x86.Build.0 = Debug|x86
{922D79D0-8F3B-4C34-8E46-8DD24778F736}.Release|x86.ActiveCfg = Release|x86
{922D79D0-8F3B-4C34-8E46-8DD24778F736}.Release|x86.Build.0 = Release|x86
{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Debug|x86.ActiveCfg = Debug|x86
{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Debug|x86.Build.0 = Debug|x86
{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Release|x86.ActiveCfg = Release|x86
{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D}.Release|x86.Build.0 = Release|x86
{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Debug|x86.ActiveCfg = Debug|x86
{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Debug|x86.Build.0 = Debug|x86
{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Release|x86.ActiveCfg = Release|x86
{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5}.Release|x86.Build.0 = Release|x86
{7AD5BC76-49BE-4700-85FA-DF869151B66C}.Debug|x86.ActiveCfg = Debug|x86
{7AD5BC76-49BE-4700-85FA-DF869151B66C}.Debug|x86.Build.0 = Debug|x86
{7AD5BC76-49BE-4700-85FA-DF869151B66C}.Release|x86.ActiveCfg = Release|x86
{7AD5BC76-49BE-4700-85FA-DF869151B66C}.Release|x86.Build.0 = Release|x86
{2A8BF715-1168-428D-869F-485CB4DEB671}.Debug|x86.ActiveCfg = Debug|x86
{2A8BF715-1168-428D-869F-485CB4DEB671}.Debug|x86.Build.0 = Debug|x86
{2A8BF715-1168-428D-869F-485CB4DEB671}.Release|x86.ActiveCfg = Release|x86
{2A8BF715-1168-428D-869F-485CB4DEB671}.Release|x86.Build.0 = Release|x86
{148422F3-1363-4839-8D27-FD9CE37A9641}.Debug|x86.ActiveCfg = Debug|x86
{148422F3-1363-4839-8D27-FD9CE37A9641}.Debug|x86.Build.0 = Debug|x86
{148422F3-1363-4839-8D27-FD9CE37A9641}.Release|x86.ActiveCfg = Release|x86
{148422F3-1363-4839-8D27-FD9CE37A9641}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EF50FA49-7F7A-4CE8-B828-918A56BD3CA0} = {1F110E75-AF31-4330-9090-89279E0814E0}
{50C2CC17-B3BC-4DB3-8901-24D18B757C23} = {1F110E75-AF31-4330-9090-89279E0814E0}
{E332E255-A604-4C4C-A08C-2D6C9295C5D2} = {1F110E75-AF31-4330-9090-89279E0814E0}
{0F6A0D37-4735-474E-B027-8F8B9E52CC5A} = {1F110E75-AF31-4330-9090-89279E0814E0}
{79BAA664-FC5B-4570-BC38-72DC6E4277CB} = {1F110E75-AF31-4330-9090-89279E0814E0}
{0267B2D7-39C6-4C11-90FF-540527EF457A} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{B5700B60-C82F-4765-9695-CE0B43BCA5D7} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{D46AF5E9-639B-4AAC-B8D3-68B064DAFAC7} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{10D7BF70-5C45-4A22-8BC3-FEFA6B122756} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{0C8C49C6-9121-49CC-9012-A1A627C2E960} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{66E86937-D762-4BF4-A0D6-317E9F76D3E8} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{97FF9699-2AF6-4485-A2F8-87A6A2FF6F9C} = {28FEA6FD-9A23-455C-AC94-43FDAF7E3B05}
{1FDCC993-010F-4E94-BA56-EF52EB9D8397} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{554DD1E6-AF06-43D6-8736-9A6CBB8379A8} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{2356D5AD-BF8E-4B84-B929-DBD245AC38CF} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{21BBBCF0-F9D8-4035-BAFA-967C3D18E34C} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{26D2883D-0BFD-4D94-AF1E-12C4FD508478} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{922D79D0-8F3B-4C34-8E46-8DD24778F736} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{76CDD6DA-9E29-4F2F-99C4-C3E30DCF8C4D} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{93FB6650-CE0F-44BD-B894-1D5CC38ECBF5} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{7AD5BC76-49BE-4700-85FA-DF869151B66C} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{2A8BF715-1168-428D-869F-485CB4DEB671} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
{148422F3-1363-4839-8D27-FD9CE37A9641} = {DE1C8A2B-6540-4FD8-84AB-06CA5FBBEE69}
EndGlobalSection
EndGlobal
... ...
No preview for this file type
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0C8C49C6-9121-49CC-9012-A1A627C2E960}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Facade</RootNamespace>
<AssemblyName>Facade</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//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.
namespace Facade
{
/// <summary>
/// MainApp startup class for Structural
/// Facade Design Pattern.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
public static void Main()
{
Facade facade = new Facade();
facade.MethodA();
facade.MethodB();
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Subsystem ClassA' class
/// </summary>
class SubSystemOne
{
public void MethodOne()
{
Console.WriteLine(" SubSystemOne Method");
}
}
/// <summary>
/// The 'Subsystem ClassB' class
/// </summary>
class SubSystemTwo
{
public void MethodTwo()
{
Console.WriteLine(" SubSystemTwo Method");
}
}
/// <summary>
/// The 'Subsystem ClassC' class
/// </summary>
class SubSystemThree
{
public void MethodThree()
{
Console.WriteLine(" SubSystemThree Method");
}
}
/// <summary>
/// The 'Subsystem ClassD' class
/// </summary>
class SubSystemFour
{
public void MethodFour()
{
Console.WriteLine(" SubSystemFour Method");
}
}
/// <summary>
/// The 'Facade' class
/// </summary>
class Facade
{
private SubSystemOne _one;
private SubSystemTwo _two;
private SubSystemThree _three;
private SubSystemFour _four;
public Facade()
{
_one = new SubSystemOne();
_two = new SubSystemTwo();
_three = new SubSystemThree();
_four = new SubSystemFour();
}
public void MethodA()
{
Console.WriteLine("\nMethodA() ---- ");
_one.MethodOne();
_two.MethodTwo();
_four.MethodFour();
}
public void MethodB()
{
Console.WriteLine("\nMethodB() ---- ");
_two.MethodTwo();
_three.MethodThree();
}
}
}
... ...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Facade")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Facade")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b5d9620b-5a16-4b64-b023-eb7220e30e95")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
... ...
No preview for this file type
No preview for this file type
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
... ...
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\bin\Debug\Facade.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\bin\Debug\Facade.pdb
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\obj\x86\Debug\Facade.exe
c:\users\rajesh.rai\documents\visual studio 2010\Projects\Design Patterns\Facade\obj\x86\Debug\Facade.pdb
... ...
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E332E255-A604-4C4C-A08C-2D6C9295C5D2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Factory_Method</RootNamespace>
<AssemblyName>Factory Method</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
... ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Factory_Method
{
/// <summary>
/// MainApp startup class for Structural
/// Factory Method Design Pattern.
/// </summary>
class MainApp
{
/// <summary>
/// Entry point into console application.
/// </summary>
static void Main()
{
// An array of creators
Creator[] creators = new Creator[2];
creators[0] = new ConcreteCreatorA();
creators[1] = new ConcreteCreatorB();
// Iterate over creators and create products
foreach (Creator creator in creators)
{
Product product = creator.FactoryMethod();
Console.WriteLine("Created {0}",
product.GetType().Name);
}
// Wait for user
Console.ReadKey();
}
}
/// <summary>
/// The 'Product' abstract class
/// </summary>
abstract class Product
{
}
/// <summary>
/// A 'ConcreteProduct' class
/// </summary>
class ConcreteProductA : Product
{
}
/// <summary>
/// A 'ConcreteProduct' class
/// </summary>
class ConcreteProductB : Product
{
}
/// <summary>
/// The 'Creator' abstract class
/// </summary>
abstract class Creator
{
public abstract Product FactoryMethod();
}
/// <summary>
/// A 'ConcreteCreator' class
/// </summary>
class ConcreteCreatorA : Creator
{
public override Product FactoryMethod()
{
return new ConcreteProductA();
}
}
/// <summary>
/// A 'ConcreteCreator' class
/// </summary>
class ConcreteCreatorB : Creator
{
public override Product FactoryMethod()
{
return new ConcreteProductB();
}
}
}
\ No newline at end of file
... ...