Skip to content

Commit 0c026d0

Browse files
author
Hasan ALTAN
committed
Third Commit
1 parent 3cdc406 commit 0c026d0

37 files changed

+919
-5
lines changed

BuilderPattern/Part1/Directories/Directory.cs

-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ public class Directory
1313
public void Constructor(IBuilder builder)
1414
{
1515
builder.ChickenBurger();
16-
17-
1816
builder.Hamburger();
19-
20-
2117
}
2218
}
2319
}
+6
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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>{CDE878FF-F370-413E-BD83-093F3698D596}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ChainOfResponsibilityPattern</RootNamespace>
10+
<AssemblyName>ChainOfResponsibilityPattern</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\Handler.cs" />
47+
<Compile Include="Part2\Abstract\PlayerHandler.cs" />
48+
<Compile Include="Part2\Concrete\HandlerAvi.cs" />
49+
<Compile Include="Part2\Concrete\Handlermp3.cs" />
50+
<Compile Include="Part2\Concrete\Handlermp4.cs" />
51+
<Compile Include="Part3\Abstract\ExpenseHandlerBase.cs" />
52+
<Compile Include="Part3\Concrete\Manager.cs" />
53+
<Compile Include="Part3\Concrete\Presedent.cs" />
54+
<Compile Include="Part3\Concrete\VicePresedent.cs" />
55+
<Compile Include="Part3\Model\Expenses.cs" />
56+
<Compile Include="Part4\Abstract\ExpenseBankHandle.cs" />
57+
<Compile Include="Part4\Concrete\BookingClerk.cs" />
58+
<Compile Include="Part4\Concrete\Ceo.cs" />
59+
<Compile Include="Part4\Concrete\SemiManager.cs" />
60+
<Compile Include="Part4\Model\Expense.cs" />
61+
<Compile Include="Program.cs" />
62+
<Compile Include="Properties\AssemblyInfo.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="App.config" />
66+
</ItemGroup>
67+
<ItemGroup>
68+
<Content Include="Theorical.txt" />
69+
</ItemGroup>
70+
<ItemGroup />
71+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
72+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ChainOfResponsibilityPattern.Part1
8+
{
9+
public class Handler
10+
{
11+
Handler next;
12+
int id;
13+
public int Limit { get; set; }
14+
15+
public Handler(int id ,Handler handler)
16+
{
17+
this.id = id;
18+
Limit = id * 1000;
19+
next = handler;
20+
21+
}
22+
public string HandlerRequest(int data)
23+
{
24+
if (data< Limit)
25+
{
26+
return $"Request for {data} handler at level {id}";
27+
28+
}
29+
else if (next !=null)
30+
{
31+
return next.HandlerRequest(data);
32+
}
33+
else
34+
{
35+
return $"Request for {data} handler by default at level";
36+
}
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ChainOfResponsibilityPattern.Part2.Abstract
8+
{
9+
public abstract class PlayerHandler
10+
{
11+
protected PlayerHandler _nextHandler;
12+
13+
public PlayerHandler nextHandler { set => _nextHandler = value; }
14+
15+
public abstract void Player(string filePath);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using ChainOfResponsibilityPattern.Part2.Abstract;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ChainOfResponsibilityPattern.Part2.Concrete
9+
{
10+
public class HandlerAvi : PlayerHandler
11+
{
12+
public override void Player(string filePath)
13+
{
14+
if (filePath.EndsWith(".avi"))
15+
{
16+
Console.WriteLine("{0} dosyası oynatılıyor..! (avi player)", filePath);
17+
}
18+
else
19+
{
20+
Console.WriteLine("{0} geçersiz dosya formatı..!", filePath);
21+
}
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using ChainOfResponsibilityPattern.Part2.Abstract;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ChainOfResponsibilityPattern.Part2.Concrete
9+
{
10+
public class Handlermp3 : PlayerHandler
11+
{
12+
public override void Player(string filePath)
13+
{
14+
if (filePath.EndsWith(".mp3"))
15+
{
16+
Console.WriteLine("{0} dosyası oynatılıyor..! (mp3 player)", filePath);
17+
18+
}
19+
else
20+
{
21+
if (_nextHandler !=null)
22+
{
23+
_nextHandler.Player(filePath);
24+
}
25+
}
26+
;
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using ChainOfResponsibilityPattern.Part2.Abstract;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ChainOfResponsibilityPattern.Part2.Concrete
9+
{
10+
public class Handlermp4 : PlayerHandler
11+
{
12+
public override void Player(string filePath)
13+
{
14+
if (filePath.EndsWith(".mp4"))
15+
{
16+
Console.WriteLine("{0} dosyası oynatılıyor..!(mp4 player)", filePath);
17+
}
18+
else
19+
{
20+
if (_nextHandler !=null)
21+
{
22+
_nextHandler.Player(filePath);
23+
}
24+
}
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using ChainOfResponsibilityPattern.Part3.Model;
2+
3+
4+
namespace ChainOfResponsibilityPattern.Part3.Abstract
5+
{
6+
public abstract class ExpenseHandlerBase
7+
{
8+
protected ExpenseHandlerBase _next;
9+
10+
public void SetHandler(ExpenseHandlerBase next) => _next = next;
11+
//Setter Dependency Injection
12+
13+
public abstract void HandleExpense(Expenses expense);
14+
15+
16+
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using ChainOfResponsibilityPattern.Part3.Abstract;
2+
using ChainOfResponsibilityPattern.Part3.Model;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace ChainOfResponsibilityPattern.Part3.Concrete
10+
{
11+
public class Manager : ExpenseHandlerBase
12+
{
13+
public override void HandleExpense(Expenses expense)
14+
{
15+
if (expense.Amount <=1000)
16+
{
17+
Console.WriteLine("Manager handle the expense..!");
18+
}
19+
else if (_next !=null)
20+
{
21+
_next.HandleExpense(expense);
22+
}
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using ChainOfResponsibilityPattern.Part3.Abstract;
2+
using ChainOfResponsibilityPattern.Part3.Model;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace ChainOfResponsibilityPattern.Part3.Concrete
10+
{
11+
public class Presedent : ExpenseHandlerBase
12+
{
13+
public override void HandleExpense(Expenses expense)
14+
{
15+
if (expense.Amount>5000)
16+
{
17+
Console.WriteLine("Presedent handle the expense..!");
18+
};
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using ChainOfResponsibilityPattern.Part3.Abstract;
2+
using ChainOfResponsibilityPattern.Part3.Model;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace ChainOfResponsibilityPattern.Part3.Concrete
10+
{
11+
public class VicePresedent : ExpenseHandlerBase
12+
{
13+
public override void HandleExpense(Expenses expense)
14+
{
15+
if (expense.Amount >1000 && expense.Amount<=5000)
16+
{
17+
Console.WriteLine("Vice presedent handle the expense..!");
18+
}
19+
else if (_next !=null)
20+
{
21+
_next.HandleExpense(expense);
22+
}
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ChainOfResponsibilityPattern.Part3.Model
8+
{
9+
public class Expenses
10+
{
11+
public string Details { get; set; }
12+
public decimal Amount { get; set; }
13+
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using ChainOfResponsibilityPattern.Part4.Model;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ChainOfResponsibilityPattern.Part4.Abstract
9+
{
10+
public abstract class ExpenseBankHandle
11+
{
12+
protected ExpenseBankHandle _next;
13+
public void SetHandler(ExpenseBankHandle next) => _next = next;
14+
//Setter Dependency Injection
15+
16+
public abstract void HandleBankAmount(Expense expense);
17+
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using ChainOfResponsibilityPattern.Part4.Abstract;
2+
using ChainOfResponsibilityPattern.Part4.Model;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace ChainOfResponsibilityPattern.Part4.Concrete
10+
{
11+
public class BookingClerk : ExpenseBankHandle
12+
{
13+
14+
15+
public override void HandleBankAmount(Expense expense)
16+
{
17+
if (expense.Amount<= 1000)
18+
{
19+
Console.WriteLine("BookingClerk handle the expense..!");
20+
}
21+
else if (_next != null)
22+
{
23+
_next.HandleBankAmount(expense);
24+
};
25+
26+
27+
}
28+
}
29+
30+
}

0 commit comments

Comments
 (0)