Skip to content

Commit 1278572

Browse files
committed
impl adapter
1 parent 449bfcf commit 1278572

File tree

7 files changed

+261
-0
lines changed

7 files changed

+261
-0
lines changed

DesignPatterns.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Creational\Pro
3737
EndProject
3838
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Creational\Singleton\Singleton.csproj", "{14333E87-2DCC-42A7-91FF-2DFEABF2AA95}"
3939
EndProject
40+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Structural", "Structural", "{05993A61-BAEE-4BA2-81F0-25B789A15F6E}"
41+
EndProject
42+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Structural\Adapter\Adapter.csproj", "{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}"
43+
EndProject
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bridge", "Structural\Bridge\Bridge.csproj", "{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}"
45+
EndProject
4046
Global
4147
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4248
Debug|Any CPU = Debug|Any CPU
@@ -143,6 +149,18 @@ Global
143149
{14333E87-2DCC-42A7-91FF-2DFEABF2AA95}.Release|Any CPU.ActiveCfg = Release|x86
144150
{14333E87-2DCC-42A7-91FF-2DFEABF2AA95}.Release|x86.ActiveCfg = Release|x86
145151
{14333E87-2DCC-42A7-91FF-2DFEABF2AA95}.Release|x86.Build.0 = Release|x86
152+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}.Debug|Any CPU.ActiveCfg = Debug|x86
153+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}.Debug|x86.ActiveCfg = Debug|x86
154+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}.Debug|x86.Build.0 = Debug|x86
155+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}.Release|Any CPU.ActiveCfg = Release|x86
156+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}.Release|x86.ActiveCfg = Release|x86
157+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}.Release|x86.Build.0 = Release|x86
158+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}.Debug|Any CPU.ActiveCfg = Debug|x86
159+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}.Debug|x86.ActiveCfg = Debug|x86
160+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}.Debug|x86.Build.0 = Debug|x86
161+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}.Release|Any CPU.ActiveCfg = Release|x86
162+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}.Release|x86.ActiveCfg = Release|x86
163+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}.Release|x86.Build.0 = Release|x86
146164
EndGlobalSection
147165
GlobalSection(SolutionProperties) = preSolution
148166
HideSolutionNode = FALSE
@@ -164,5 +182,7 @@ Global
164182
{040AFA71-3175-4C6C-8DB2-98810D3E98F4} = {B9EDC98E-1E00-4320-A39F-7D64F44A2D3C}
165183
{598AAD5B-C38A-4AC8-89C5-14CAC60AE46E} = {B9EDC98E-1E00-4320-A39F-7D64F44A2D3C}
166184
{14333E87-2DCC-42A7-91FF-2DFEABF2AA95} = {B9EDC98E-1E00-4320-A39F-7D64F44A2D3C}
185+
{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0} = {05993A61-BAEE-4BA2-81F0-25B789A15F6E}
186+
{FECD9206-68C5-4F31-A7AB-AD876E05ABDA} = {05993A61-BAEE-4BA2-81F0-25B789A15F6E}
167187
EndGlobalSection
168188
EndGlobal

Structural/Adapter/Adapter.csproj

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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>{72F9E83E-462A-4A2F-88BB-1A8A1AE33AE0}</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+
<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>

Structural/Adapter/Program.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace Adapter {
7+
8+
interface ITarget {
9+
10+
void Request();
11+
12+
}
13+
14+
class Adapter : ITarget {
15+
16+
private readonly Adaptee _adaptee;
17+
18+
public Adapter(Adaptee adaptee) {
19+
this._adaptee = adaptee;
20+
}
21+
22+
void ITarget.Request() {
23+
this._adaptee.PerformRequest();
24+
}
25+
}
26+
27+
class Adaptee {
28+
29+
public void PerformRequest() {
30+
Console.WriteLine("Addaptee perform request.");
31+
}
32+
33+
}
34+
35+
class Program {
36+
37+
static void Main(string[] args) {
38+
ITarget target = new Adapter(new Adaptee());
39+
target.Request();
40+
41+
Console.ReadLine();
42+
}
43+
}
44+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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("")]
12+
[assembly: AssemblyProduct("Adapter")]
13+
[assembly: AssemblyCopyright("Copyright © 2012")]
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("c245f461-c21b-4eb6-a7be-291d08c4047d")]
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")]

Structural/Bridge/Bridge.csproj

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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>{FECD9206-68C5-4F31-A7AB-AD876E05ABDA}</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+
<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>

Structural/Bridge/Program.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace Bridge {
7+
class Program {
8+
static void Main(string[] args) {
9+
}
10+
}
11+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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("")]
12+
[assembly: AssemblyProduct("Bridge")]
13+
[assembly: AssemblyCopyright("Copyright © 2012")]
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("a0448aef-795d-4394-ad5b-f6329481a579")]
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")]

0 commit comments

Comments
 (0)