main
syneffort 2 years ago
parent 6f5e1689e7
commit 6f69b357dd
  1. 10
      DesignPatternGuru/Bridge/Bridge.csproj
  2. 24
      DesignPatternGuru/Bridge/Bridges/Abstraction.cs
  3. 21
      DesignPatternGuru/Bridge/Bridges/ExtendedAbstraction.cs
  4. 17
      DesignPatternGuru/Bridge/Client.cs
  5. 16
      DesignPatternGuru/Bridge/Implementations/ConcreteImplementationA.cs
  6. 16
      DesignPatternGuru/Bridge/Implementations/ConcreteImplementationB.cs
  7. 13
      DesignPatternGuru/Bridge/Implementations/IImplementation.cs
  8. 22
      DesignPatternGuru/Bridge/Program.cs
  9. 7
      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,24 @@
using Bridge.Implementations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bridge.Bridges
{
internal class Abstraction
{
protected IImplementation _implementation;
public Abstraction(IImplementation implementation)
{
_implementation = implementation;
}
public virtual string Operation()
{
return $"Abstract: Base operation with: {_implementation.OperationImplementation()}";
}
}
}

@ -0,0 +1,21 @@
using Bridge.Implementations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bridge.Bridges
{
internal class ExtendedAbstraction : Abstraction
{
public ExtendedAbstraction(IImplementation implementation) : base(implementation)
{
}
public override string Operation()
{
return $"ExtendedAbstraction: Extended operation with: {_implementation.OperationImplementation()}";
}
}
}

@ -0,0 +1,17 @@
using Bridge.Bridges;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bridge
{
internal class Client
{
public void ClientCode(Abstraction abstraction)
{
Console.WriteLine(abstraction.Operation());
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bridge.Implementations
{
internal class ConcreteImplementationA : IImplementation
{
public string OperationImplementation()
{
return "ConcreteImplementationA: The result in platform A.";
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bridge.Implementations
{
internal class ConcreteImplementationB : IImplementation
{
public string OperationImplementation()
{
return "ConcreteImplementationB: The result in platform B.";
}
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bridge.Implementations
{
internal interface IImplementation
{
string OperationImplementation();
}
}

@ -0,0 +1,22 @@
using Bridge.Bridges;
using Bridge.Implementations;
namespace Bridge
{
internal class Program
{
static void Main(string[] args)
{
Client client = new Client();
Abstraction abstraction;
abstraction = new Abstraction(new ConcreteImplementationA());
client.ClientCode(abstraction);
Console.WriteLine();
abstraction = new ExtendedAbstraction(new ConcreteImplementationB());
client.ClientCode(abstraction);
}
}
}

@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StructuralPatterns", "Struc
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adapter", "Adapter\Adapter.csproj", "{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bridge", "Bridge\Bridge.csproj", "{60D1EE6E-282D-4613-8B1D-DE355768DCBA}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -49,6 +51,10 @@ Global
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Release|Any CPU.Build.0 = Release|Any CPU {4E8B1160-0BD2-42FD-9DB8-991CAA88578A}.Release|Any CPU.Build.0 = Release|Any CPU
{60D1EE6E-282D-4613-8B1D-DE355768DCBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60D1EE6E-282D-4613-8B1D-DE355768DCBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60D1EE6E-282D-4613-8B1D-DE355768DCBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{60D1EE6E-282D-4613-8B1D-DE355768DCBA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -60,6 +66,7 @@ Global
{3A8E007E-79D4-499B-8D19-BF745EC9C68E} = {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} {79AC3F3A-CE95-40C4-94E6-31CC85494E41} = {C470237E-3C3B-49E3-BA4C-86884EC28413}
{4E8B1160-0BD2-42FD-9DB8-991CAA88578A} = {0B9333EC-FB73-4FEE-B600-9ECCD5A356B1} {4E8B1160-0BD2-42FD-9DB8-991CAA88578A} = {0B9333EC-FB73-4FEE-B600-9ECCD5A356B1}
{60D1EE6E-282D-4613-8B1D-DE355768DCBA} = {0B9333EC-FB73-4FEE-B600-9ECCD5A356B1}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3E5A9C6B-2E8A-466E-B5E0-4379902EFFAC} SolutionGuid = {3E5A9C6B-2E8A-466E-B5E0-4379902EFFAC}

Loading…
Cancel
Save