Add Design Patterns

This commit is contained in:
2026-01-20 10:30:21 +01:00
parent 4a83bd3d5a
commit b9e8eb590c
24 changed files with 298 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
namespace ProxyLib;
internal class ConcreteSubject: ISubject
{
public void Log()
{
Console.WriteLine("ConcreteSubject Log");
}
}

6
ProxyLib/ISubject.cs Normal file
View File

@@ -0,0 +1,6 @@
namespace ProxyLib;
public interface ISubject
{
void Log();
}

9
ProxyLib/ProxyLib.csproj Normal file
View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

13
ProxyLib/SubjectProxy.cs Normal file
View File

@@ -0,0 +1,13 @@
namespace ProxyLib;
public class SubjectProxy : ISubject
{
public bool CanLog { get; set; }
private readonly ISubject _subject = new ConcreteSubject();
public void Log()
{
if (!CanLog) return;
_subject.Log();
}
}