Skip to content

Commit b28b62b

Browse files
author
Hasan ALTAN
committed
3 patterns added
1 parent 0e56f75 commit b28b62b

34 files changed

+704
-2
lines changed

DecoratorPattern/DecoratorPattern.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
<ItemGroup>
6060
<None Include="App.config" />
6161
</ItemGroup>
62-
<ItemGroup />
62+
<ItemGroup>
63+
<Content Include="TextFile1.txt" />
64+
</ItemGroup>
6365
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6466
</Project>

DecoratorPattern/TextFile1.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Decorator Pattern
2+
3+
This pattern interest with structural of object.Moreover,"Decorator Pattern" belongs to Structural Categories.
4+
For instance;
5+
Just think about a coffeeshop;
6+
when you go to Coffeeshop u want to a coffee and teller says u " Would u want to milk" and " Would u want to sugar" then i assume u say yes.Teller adds them to your coffer.As a conclusion,Did it change your coffer orginially? i mean it didn't change ur coffee to coke.It is coffee but teller added milk and sugar.This pattern same logic.

DesignPatterns.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChainOfResponsibilityPatter
1313
EndProject
1414
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecoratorPattern", "DecoratorPattern\DecoratorPattern.csproj", "{5811DDBE-773C-48D8-BBC3-29B0D7A5C9A9}"
1515
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObserverPattern", "ObserverPattern\ObserverPattern.csproj", "{8F094A80-BFBA-4CCE-B5CB-DD3E62EE53BC}"
17+
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryMethodPattern", "FactoryMethodPattern\FactoryMethodPattern.csproj", "{C560D63D-E230-4463-8E41-82E4C1EE503A}"
19+
EndProject
1620
Global
1721
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1822
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +43,14 @@ Global
3943
{5811DDBE-773C-48D8-BBC3-29B0D7A5C9A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
4044
{5811DDBE-773C-48D8-BBC3-29B0D7A5C9A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
4145
{5811DDBE-773C-48D8-BBC3-29B0D7A5C9A9}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{8F094A80-BFBA-4CCE-B5CB-DD3E62EE53BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{8F094A80-BFBA-4CCE-B5CB-DD3E62EE53BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{8F094A80-BFBA-4CCE-B5CB-DD3E62EE53BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{8F094A80-BFBA-4CCE-B5CB-DD3E62EE53BC}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{C560D63D-E230-4463-8E41-82E4C1EE503A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{C560D63D-E230-4463-8E41-82E4C1EE503A}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{C560D63D-E230-4463-8E41-82E4C1EE503A}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{C560D63D-E230-4463-8E41-82E4C1EE503A}.Release|Any CPU.Build.0 = Release|Any CPU
4254
EndGlobalSection
4355
GlobalSection(SolutionProperties) = preSolution
4456
HideSolutionNode = FALSE

DesignPatterns/DependencyInjection.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,5 @@
8282
<ItemGroup>
8383
<None Include="App.config" />
8484
</ItemGroup>
85-
<ItemGroup />
8685
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8786
</Project>

FactoryMethodPattern/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{C560D63D-E230-4463-8E41-82E4C1EE503A}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>FactoryMethodPattern</RootNamespace>
10+
<AssemblyName>FactoryMethodPattern</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Part1\Concrete\DefaultProduct.cs" />
47+
<Compile Include="Part1\Concrete\Product_A.cs" />
48+
<Compile Include="Part1\Concrete\Product_B.cs" />
49+
<Compile Include="Part1\Creator\ProductCreator.cs" />
50+
<Compile Include="Part1\Interface\IProduct.cs" />
51+
<Compile Include="Part2\Concrete\PLSLoggerFactory.cs" />
52+
<Compile Include="Part2\Concrete\PLSLogger.cs" />
53+
<Compile Include="Part2\Concrete\SystemLogger.cs" />
54+
<Compile Include="Part2\Concrete\SystemLoggerFactory.cs" />
55+
<Compile Include="Part2\Creator\SystemManager.cs" />
56+
<Compile Include="Part2\Interface\ILogger.cs" />
57+
<Compile Include="Part2\Interface\ILoggerFactory.cs" />
58+
<Compile Include="Program.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<None Include="App.config" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<Content Include="Theorical.txt" />
66+
</ItemGroup>
67+
<ItemGroup />
68+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
69+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using FactoryMethodPattern.Part1.Interface;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace FactoryMethodPattern.Part1.Concrete
9+
{
10+
public class DefaultProduct : IProduct
11+
12+
{
13+
public string ShipFrom()
14+
{
15+
return "not avaliable";
16+
}
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using FactoryMethodPattern.Part1.Interface;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace FactoryMethodPattern.Part1.Concrete
9+
{
10+
public class Product_A : IProduct
11+
{
12+
public string ShipFrom()
13+
{
14+
return "South Africa";
15+
}
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using FactoryMethodPattern.Part1.Interface;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace FactoryMethodPattern.Part1.Concrete
9+
{
10+
public class Product_B : IProduct
11+
{
12+
13+
public string ShipFrom()=>"from Columbia" ;
14+
15+
}
16+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using FactoryMethodPattern.Part1.Concrete;
2+
using FactoryMethodPattern.Part1.Interface;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace FactoryMethodPattern.Part1.Creator
10+
{
11+
public class ProductCreator:IProduct
12+
{
13+
public IProduct FactoryMethod(int month)
14+
{
15+
if (month >= 4 && month <= 11)
16+
{
17+
return new Product_A();
18+
}
19+
else if {(month ==1 || month ==2 || month == 3 )
20+
{
21+
return new Product_B();
22+
23+
}
24+
25+
}
26+
else
27+
{
28+
return new DefaultProduct();
29+
}
30+
}
31+
32+
public string ShipFrom()
33+
{
34+
throw new NotImplementedException();
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)