From b5be0db52b0ba1829d81fc44467f635cc954b0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Wed, 17 Sep 2025 17:50:29 +0200 Subject: [PATCH] Implemented IoC container --- App/App.csproj | 1 + App/Program.cs | 37 +++++++++++++++++++++++++++++-------- App/UI/MainWindow.cs | 1 - 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/App/App.csproj b/App/App.csproj index a36c36b..9a5dfe9 100644 --- a/App/App.csproj +++ b/App/App.csproj @@ -9,6 +9,7 @@ + diff --git a/App/Program.cs b/App/Program.cs index 1af249a..f54c071 100644 --- a/App/Program.cs +++ b/App/Program.cs @@ -1,9 +1,30 @@ -var application = Adw.Application.New("org.typomustakes.keychain", Gio.ApplicationFlags.FlagsNone); -application.OnActivate += (sender, args) => -{ - var window = new App.UI.MainWindow().Window; - window.Application = (Adw.Application)sender; - window.Show(); -}; +using Microsoft.Extensions.DependencyInjection; -return application.RunWithSynchronizationContext(null); \ No newline at end of file +namespace App; + +class Program +{ + private static ServiceProvider? provider; + + static int Main() + { + provider = SetupServices(); + + var application = Adw.Application.New("org.typomustakes.keychain", Gio.ApplicationFlags.FlagsNone); + application.OnActivate += (sender, args) => + { + var window = new App.UI.MainWindow().Window; + window.Application = (Adw.Application)sender; + window.Show(); + }; + + return application.RunWithSynchronizationContext(null); + } + + private static ServiceProvider SetupServices() + { + var services = new ServiceCollection(); + services.AddTransient(); + return services.BuildServiceProvider(); + } +} \ No newline at end of file diff --git a/App/UI/MainWindow.cs b/App/UI/MainWindow.cs index a5b8296..e9654b1 100644 --- a/App/UI/MainWindow.cs +++ b/App/UI/MainWindow.cs @@ -61,7 +61,6 @@ public class MainWindow shortcuts.Add(new PasswordStoreShortcut(displayName:"Default", path:Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"/.password_store")); } - // Example of reactive property updates public void UpdateShortcutName(PasswordStoreShortcut shortcut, string newName) { shortcut.DisplayName = newName; // This will automatically update the UI row