From 39d7187713432d7bcf8c11911ff4a54c3d64c1c3 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 23 Feb 2025 13:27:39 +0800 Subject: [PATCH] Use constructor injection for updater --- Flow.Launcher.Core/Updater.cs | 7 ++++++- Flow.Launcher/App.xaml.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs index 7a25447b4..dd0864c19 100644 --- a/Flow.Launcher.Core/Updater.cs +++ b/Flow.Launcher.Core/Updater.cs @@ -23,10 +23,15 @@ namespace Flow.Launcher.Core { public class Updater { - private readonly IPublicAPI API = Ioc.Default.GetRequiredService(); + private readonly IPublicAPI API; public string GitHubRepository { get; set; } + public Updater(IPublicAPI publicAPI) + { + API = publicAPI; + } + public void Initialize(string gitHubRepository) { GitHubRepository = gitHubRepository; diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 5f7f097e0..b52ae7196 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -45,7 +45,7 @@ namespace Flow.Launcher .UseContentRoot(AppContext.BaseDirectory) .ConfigureServices(services => services .AddSingleton(_ => _settings) - .AddSingleton() + .AddSingleton(sp => new Updater(sp.GetRequiredService())) .AddSingleton() .AddSingleton() .AddSingleton()