adapter pattern

remotes/origin/master
syneffort 3 years ago
parent bd9e220663
commit 94953489c4
  1. 58
      DesignPattern/Adapter/Adapter.csproj
  2. 6
      DesignPattern/Adapter/App.config
  3. 31
      DesignPattern/Adapter/Client.cs
  4. 20
      DesignPattern/Adapter/HdmiAdapter.cs
  5. 18
      DesignPattern/Adapter/HdmiToVgaAdapter.cs
  6. 13
      DesignPattern/Adapter/IAdapter.cs
  7. 20
      DesignPattern/Adapter/LegacyVGA.cs
  8. 24
      DesignPattern/Adapter/Program.cs
  9. 36
      DesignPattern/Adapter/Properties/AssemblyInfo.cs
  10. 6
      DesignPattern/DesignPattern.sln

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B7ADC626-22C7-4BE8-9385-ABA3AD428878}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Adapter</RootNamespace>
<AssemblyName>Adapter</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Client.cs" />
<Compile Include="HdmiAdapter.cs" />
<Compile Include="HdmiToVgaAdapter.cs" />
<Compile Include="IAdapter.cs" />
<Compile Include="LegacyVGA.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter
{
class Client
{
private bool vgaMonitor = true;
public void HowToUse()
{
IAdapter hdmi;
if (vgaMonitor)
hdmi = new HdmiToVgaAdapter();
else
hdmi = new HdmiAdapter();
byte[] data = new byte[] { byte.MinValue, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, byte.MaxValue };
DisplyData(hdmi, data);
}
private void DisplyData(IAdapter adapter, byte[] data)
{
adapter.Disply(data);
}
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter
{
class HdmiAdapter : IAdapter
{
public void Disply(byte[] data)
{
Console.WriteLine("HDMI");
foreach (byte b in data)
{
Console.WriteLine($"{b} ");
}
}
}
}

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter
{
class HdmiToVgaAdapter : IAdapter
{
private LegacyVGA vga = new LegacyVGA();
public void Disply(byte[] data)
{
vga.Display(data);
}
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter
{
interface IAdapter
{
void Disply(byte[] data);
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter
{
class LegacyVGA
{
public void Display(byte[] data)
{
Console.WriteLine("VGA");
foreach (byte b in data)
{
Console.WriteLine($"{b} ");
}
}
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter
{
/*
* :
* : ,
*
*/
class Program
{
static void Main(string[] args)
{
Client client = new Client();
client.HowToUse();
Console.ReadKey();
}
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
// 이러한 특성 값을 변경하세요.
[assembly: AssemblyTitle("Adapter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Adapter")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
[assembly: ComVisible(false)]
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
[assembly: Guid("b7adc626-22c7-4be8-9385-aba3ad428878")]
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
//
// 주 버전
// 부 버전
// 빌드 번호
// 수정 버전
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prot
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObjectPool", "ObjectPool\ObjectPool.csproj", "{64993D9F-0D9E-42B6-B032-800DA2DD453B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{B7ADC626-22C7-4BE8-9385-ABA3AD428878}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -39,6 +41,10 @@ Global
{64993D9F-0D9E-42B6-B032-800DA2DD453B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64993D9F-0D9E-42B6-B032-800DA2DD453B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64993D9F-0D9E-42B6-B032-800DA2DD453B}.Release|Any CPU.Build.0 = Release|Any CPU
{B7ADC626-22C7-4BE8-9385-ABA3AD428878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7ADC626-22C7-4BE8-9385-ABA3AD428878}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7ADC626-22C7-4BE8-9385-ABA3AD428878}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7ADC626-22C7-4BE8-9385-ABA3AD428878}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save