From 449c4ec95cbb7e5a135c6630e6b954104b501f31 Mon Sep 17 00:00:00 2001 From: Michael Jolley Date: Sat, 15 Nov 2025 17:03:12 -0600 Subject: [PATCH] More of the service stuff --- .../TopLevelCommandManager.cs | 4 ++-- src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs | 8 +++++--- .../cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs index c113b508d3..7e38a96fa8 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs @@ -34,10 +34,10 @@ public partial class TopLevelCommandManager : ObservableObject, TaskScheduler IPageContext.Scheduler => _taskScheduler; - public TopLevelCommandManager(IServiceProvider serviceProvider) + public TopLevelCommandManager(IServiceProvider serviceProvider, TaskScheduler taskScheduler) { _serviceProvider = serviceProvider; - _taskScheduler = _serviceProvider.GetService()!; + _taskScheduler = taskScheduler; WeakReferenceMessenger.Default.Register(this); _reloadCommandsGate = new(ReloadAllCommandsAsyncCore); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs index b99aee1958..cffbd65c94 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs @@ -111,6 +111,7 @@ public partial class App : Application services.AddSingleton(TaskScheduler.FromCurrentSynchronizationContext()); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); // TODO: Register ILogger @@ -170,16 +171,17 @@ public partial class App : Application services.AddSingleton(); // ViewModels - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); // Views - services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddTransient(); + + // Settings Pages services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs index 8f5c8a6b8e..41a689823d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs @@ -74,7 +74,10 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page, public event PropertyChangedEventHandler? PropertyChanged; - public ShellPage(ShellViewModel shellViewModel, SettingsModel settingsModel, TopLevelCommandManager topLevelCommandManager) + public ShellPage( + ShellViewModel shellViewModel, + SettingsModel settingsModel, + TopLevelCommandManager topLevelCommandManager) { this.InitializeComponent();