main
syneffort 2 years ago
parent 8ff0f9df49
commit 6f5e1689e7
  1. 10
      DesignPatternGuru/Adapter/Adapter.csproj
  2. 16
      DesignPatternGuru/Adapter/Adapters/Adaptee.cs
  3. 23
      DesignPatternGuru/Adapter/Adapters/Adapter.cs
  4. 13
      DesignPatternGuru/Adapter/Adapters/ITarget.cs
  5. 18
      DesignPatternGuru/Adapter/Program.cs
  6. 15
      DesignPatternGuru/DesignPatternGuru.sln

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter.Adapters
{
internal class Adaptee
{
public string GetSpecificRequest()
{
return "Specific request.";
}
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter.Adapters
{
internal class Adapter : ITarget
{
private readonly Adaptee _adaptee;
public Adapter(Adaptee adaptee)
{
_adaptee = adaptee;
}
public string GetRequest()
{
return $"This is wrapped request: '{_adaptee.GetSpecificRequest()}'";
}
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adapter.Adapters
{
internal interface ITarget
{
string GetRequest();
}
}

@ -0,0 +1,18 @@
using Adapter.Adapters;
namespace Adapter
{
internal class Program
{
static void Main(string[] args)
{
Adaptee adaptee = new Adaptee();
ITarget target = new Adapter.Adapters.Adapter(adaptee);
Console.WriteLine("Adaptee interface is incompatible with the client.");
Console.WriteLine("But with adapter client can call it's method");
Console.WriteLine(target.GetRequest());
}
}
}

@ -7,13 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryMethod", "FactoryMet
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFactory", "AbstractFactory\AbstractFactory.csproj", "{8310590F-E10F-4845-8737-AF3CEF4583B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{FD2896D5-8199-4036-8D45-1CC0D3B4B79F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Builder", "Builder\Builder.csproj", "{FD2896D5-8199-4036-8D45-1CC0D3B4B79F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prototype", "Prototype\Prototype.csproj", "{3A8E007E-79D4-499B-8D19-BF745EC9C68E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prototype", "Prototype\Prototype.csproj", "{3A8E007E-79D4-499B-8D19-BF745EC9C68E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CreationalPatterns", "CreationalPatterns", "{C470237E-3C3B-49E3-BA4C-86884EC28413}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Singleton\Singleton.csproj", "{79AC3F3A-CE95-40C4-94E6-31CC85494E41}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Singleton", "Singleton\Singleton.csproj", "{79AC3F3A-CE95-40C4-94E6-31CC85494E41}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StructuralPatterns", "StructuralPatterns", "{0B9333EC-FB73-4FEE-B600-9ECCD5A356B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -41,6 +45,10 @@ Global
{79AC3F3A-CE95-40C4-94E6-31CC85494E41}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79AC3F3A-CE95-40C4-94E6-31CC85494E41}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79AC3F3A-CE95-40C4-94E6-31CC85494E41}.Release|Any CPU.Build.0 = Release|Any CPU
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -51,6 +59,7 @@ Global
{FD2896D5-8199-4036-8D45-1CC0D3B4B79F} = {C470237E-3C3B-49E3-BA4C-86884EC28413}
{3A8E007E-79D4-499B-8D19-BF745EC9C68E} = {C470237E-3C3B-49E3-BA4C-86884EC28413}
{79AC3F3A-CE95-40C4-94E6-31CC85494E41} = {C470237E-3C3B-49E3-BA4C-86884EC28413}
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A} = {0B9333EC-FB73-4FEE-B600-9ECCD5A356B1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3E5A9C6B-2E8A-466E-B5E0-4379902EFFAC}

Loading…
Cancel
Save