registrated new services in DI container
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Windows;
|
||||
using CursorLang.Models;
|
||||
using CursorLang.Services;
|
||||
using CursorLang.ViewModels;
|
||||
using CursorLang.Views;
|
||||
@@ -7,9 +6,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace CursorLang;
|
||||
|
||||
/// <summary>
|
||||
/// Композиционный корень: собирает контейнер и запускает окно настроек.
|
||||
/// </summary>
|
||||
// ReSharper disable once RedundantExtendsListEntry
|
||||
public partial class App : Application
|
||||
{
|
||||
private ServiceProvider? _services;
|
||||
@@ -41,6 +38,8 @@ public partial class App : Application
|
||||
MainWindow = _services.GetRequiredService<MainWindow>();
|
||||
MainWindow.Show();
|
||||
|
||||
_ = _services.GetRequiredService<SettingsViewModel>().InitializeAsync();
|
||||
_ = _services.GetRequiredService<UpdateViewModel>().StartAsync();
|
||||
_services.GetRequiredService<LayoutNotificationCoordinator>().Start();
|
||||
_services.GetRequiredService<CapsLockSwitchCoordinator>().Start();
|
||||
}
|
||||
@@ -75,9 +74,10 @@ public partial class App : Application
|
||||
MainWindow.Activate();
|
||||
}
|
||||
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
internal static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(new KeyboardLayoutOptions());
|
||||
services.AddSingleton(new UpdateOptions());
|
||||
|
||||
services.AddSingleton<SettingsService>();
|
||||
services.AddSingleton(provider => provider.GetRequiredService<SettingsService>().Load());
|
||||
@@ -88,6 +88,8 @@ public partial class App : Application
|
||||
services.AddSingleton<MainWindowPlacement>();
|
||||
|
||||
services.AddSingleton<ILocalizationService, LocalizationService>();
|
||||
services.AddSingleton<IStartupService, StartupService>();
|
||||
services.AddSingleton<IUpdateService, UpdateService>();
|
||||
services.AddSingleton<IKeyboardLayoutService, KeyboardLayoutService>();
|
||||
services.AddSingleton<ILayoutPopupService, LayoutPopupService>();
|
||||
services.AddSingleton<ICapsLockHotkeyService, CapsLockHotkeyService>();
|
||||
@@ -95,9 +97,11 @@ public partial class App : Application
|
||||
services.AddSingleton<CapsLockSwitchCoordinator>();
|
||||
|
||||
services.AddSingleton<LayoutPopupViewModel>();
|
||||
services.AddSingleton<UpdateViewModel>();
|
||||
services.AddSingleton<SettingsViewModel>();
|
||||
|
||||
services.AddSingleton<LayoutPopupWindow>();
|
||||
services.AddSingleton<ILayoutPopupWindow>(provider => provider.GetRequiredService<LayoutPopupWindow>());
|
||||
services.AddSingleton<MainWindow>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user