remotes/origin/master
syneffort 3 years ago
parent 13d48f9d53
commit 8f6fa63dd1
  1. 6
      DesignPattern/Builder/App.config
  2. 21
      DesignPattern/Builder/Bed.cs
  3. 12
      DesignPattern/Builder/Builder.cs
  4. 59
      DesignPattern/Builder/Builder.csproj
  5. 20
      DesignPattern/Builder/Client.cs
  6. 23
      DesignPattern/Builder/Director.cs
  7. 18
      DesignPattern/Builder/IBedBuilder.cs
  8. 23
      DesignPattern/Builder/Program.cs
  9. 36
      DesignPattern/Builder/Properties/AssemblyInfo.cs
  10. 54
      DesignPattern/Builder/Simons.cs
  11. 6
      DesignPattern/DesignPattern.sln

@ -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,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
public class Bed
{
public string Frame { get; set; }
public string Mattress { get; set; }
public string Pillow { get; set; }
public string Sheet { get; set; }
public override string ToString()
{
return $"Frame: {Frame}, Mattress: {Mattress}, Pillow: {Pillow}, Sheet: {Sheet}";
}
}
}

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
class Builder
{
}
}

@ -0,0 +1,59 @@
<?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>{01181F37-48B4-4C0B-BE41-F8693C8B9E81}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Builder</RootNamespace>
<AssemblyName>Builder</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="Bed.cs" />
<Compile Include="Builder.cs" />
<Compile Include="Client.cs" />
<Compile Include="Director.cs" />
<Compile Include="IBedBuilder.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Simons.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
class Client
{
public static void HowToTest()
{
IBedBuilder builder = new Simons();
Director director = new Director();
Bed bed = director.Construct(builder);
Console.WriteLine(bed.ToString());
}
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
class Director
{
public Bed Construct(IBedBuilder builder)
{
Bed bed = builder
.MakeFrame()
.MakeMattress()
.MakeSheet("White")
.MakePillow(10)
.Build();
return bed;
}
}
}

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
/*Builder (Fluent)*/
public interface IBedBuilder
{
IBedBuilder MakeFrame();
IBedBuilder MakeMattress();
IBedBuilder MakeSheet(string sheet);
IBedBuilder MakePillow(int size);
Bed Build();
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
/*
* :
* :
* Director라는 Builder의
* Build
*/
class Program
{
static void Main(string[] args)
{
Client.HowToTest();
Console.ReadKey();
}
}
}

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

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder
{
/*Concrete Builder*/
public class Simons : IBedBuilder
{
private Bed _bed = new Bed();
private int pillowSize = 0;
private string sheetName;
public Bed Build()
{
_bed.Pillow = $"Pillow Size#{pillowSize}";
_bed.Sheet = $"Sheet {sheetName}";
return _bed;
}
public IBedBuilder MakeFrame()
{
_bed.Frame = (DateTime.Now.Month > 5 && DateTime.Now.Month < 9) ?
"Simons Summer Frame" :
"Simons Wood Frame";
return this;
}
public IBedBuilder MakeMattress()
{
_bed.Mattress = "Simons Mattress";
return this;
}
public IBedBuilder MakePillow(int size)
{
pillowSize = size;
return this;
}
public IBedBuilder MakeSheet(string sheet)
{
sheetName = sheet;
return this;
}
}
}

@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.32630.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Singleton\Singleton.csproj", "{37FE4D0C-A213-4EA5-B3EF-DB2DB3971ACE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{01181F37-48B4-4C0B-BE41-F8693C8B9E81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{37FE4D0C-A213-4EA5-B3EF-DB2DB3971ACE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37FE4D0C-A213-4EA5-B3EF-DB2DB3971ACE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37FE4D0C-A213-4EA5-B3EF-DB2DB3971ACE}.Release|Any CPU.Build.0 = Release|Any CPU
{01181F37-48B4-4C0B-BE41-F8693C8B9E81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01181F37-48B4-4C0B-BE41-F8693C8B9E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01181F37-48B4-4C0B-BE41-F8693C8B9E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01181F37-48B4-4C0B-BE41-F8693C8B9E81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save