From 8fc2fbc7f13fe97167edb80c329d6389e499ebcd Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Mon, 15 Jun 2026 00:37:30 +0200 Subject: [PATCH] Removed SandboxProject --- .idea/.idea.Syrette/.idea/discord.xml | 14 +++++ DISandbox/DISandbox.csproj | 14 ----- DISandbox/Program.cs | 84 --------------------------- Syrette.sln | 5 -- 4 files changed, 14 insertions(+), 103 deletions(-) create mode 100644 .idea/.idea.Syrette/.idea/discord.xml delete mode 100644 DISandbox/DISandbox.csproj delete mode 100644 DISandbox/Program.cs diff --git a/.idea/.idea.Syrette/.idea/discord.xml b/.idea/.idea.Syrette/.idea/discord.xml new file mode 100644 index 0000000..912db82 --- /dev/null +++ b/.idea/.idea.Syrette/.idea/discord.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/DISandbox/DISandbox.csproj b/DISandbox/DISandbox.csproj deleted file mode 100644 index a4dda08..0000000 --- a/DISandbox/DISandbox.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - enable - enable - net10.0;net8.0 - - - - - - - diff --git a/DISandbox/Program.cs b/DISandbox/Program.cs deleted file mode 100644 index 92d9780..0000000 --- a/DISandbox/Program.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Syrette; - -namespace DISandbox; - -interface IService { - public void Log(string message); -} - -class Service : IService { - public void Log(string message) { - Console.WriteLine($"[Service] {message}"); - } -} - -class AnotherService : IService { - public void Log(string message) { - Console.WriteLine($"[AnotherService] {message}"); - } -} - -interface IOtherService { - public Guid Id { get; } - - public void ShowId() => Console.WriteLine($"[OtherService] ID: {Id}"); -} - -class GuidService : IOtherService { - public Guid Id { get; } = Guid.NewGuid(); -} -public interface INotRegisteredService { - void DoSomething(); -} - -class GuidDependantService { - private readonly IService logService; - private readonly IOtherService? guidService; - - public GuidDependantService(IService logService, INotRegisteredService guidService) { - this.logService = logService; - } - - public GuidDependantService(IService logService, IOtherService guidService) { - this.logService = logService; - this.guidService = guidService; - } - - public void LogWithId(string message) { - logService.Log($"[GuidDependantService] {message} (ID: {guidService?.Id})"); - } -} - -public interface ICacheService { - public Uri CacheLocation { get; set; } -} - -public class CacheService : ICacheService { - public required Uri CacheLocation { get; set; } - public CacheService() => CacheLocation = new Uri("http://default.cache"); - public CacheService(Uri cacheLocation) => CacheLocation = cacheLocation; -} - -static class Program { - static void Main(string[] args) { - var container = new ServiceContainer() - .AddSingleton() - .AddTransient() - .AddTransient() - .AddTransient(); - - var service = container.GetService(); - service.Log("Hello, Dependency Injection!"); - container.GetService().ShowId(); - container.GetService().LogWithId("Hello, sent from the dependency."); - container.GetService().Log("Goodbye, Dependency Injection!"); - var res = container.GetServices(); - - var testContainer = new ServiceContainer() - .AddSingleton(new Uri("http://cache.local")); - var iCacheService = testContainer.GetService(); - Console.WriteLine($"[ICacheService] {iCacheService.CacheLocation}"); - var cacheService = testContainer.GetService(); - Console.WriteLine($"[CacheService] {cacheService.CacheLocation}"); - } -} \ No newline at end of file diff --git a/Syrette.sln b/Syrette.sln index d98a699..d547e9a 100644 --- a/Syrette.sln +++ b/Syrette.sln @@ -2,7 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syrette", "Syrette\Syrette.csproj", "{4730ABA2-3979-4B74-A3FF-042F6C3C47D6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DISandbox", "DISandbox\DISandbox.csproj", "{536F5490-926D-4B2A-8F07-9A7D1F8B9381}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -14,9 +13,5 @@ Global {4730ABA2-3979-4B74-A3FF-042F6C3C47D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {4730ABA2-3979-4B74-A3FF-042F6C3C47D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {4730ABA2-3979-4B74-A3FF-042F6C3C47D6}.Release|Any CPU.Build.0 = Release|Any CPU - {536F5490-926D-4B2A-8F07-9A7D1F8B9381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {536F5490-926D-4B2A-8F07-9A7D1F8B9381}.Debug|Any CPU.Build.0 = Debug|Any CPU - {536F5490-926D-4B2A-8F07-9A7D1F8B9381}.Release|Any CPU.ActiveCfg = Release|Any CPU - {536F5490-926D-4B2A-8F07-9A7D1F8B9381}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal