feat(configmanager): complete service registrations in App.axaml.cs
Add IDialogService registration using factory pattern for window access. Add GetMainWindow helper method to provide window reference for dialogs.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using JdeScoping.ConfigManager.Services;
|
||||
@@ -15,17 +16,13 @@ public partial class App : Application
|
||||
/// </summary>
|
||||
public static IServiceProvider Services { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the Avalonia XAML loader.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the framework initialization is complete; configures services and sets the main window.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
@@ -60,7 +57,16 @@ public partial class App : Application
|
||||
services.AddSingleton<IValidationService, ValidationService>();
|
||||
services.AddScoped<IConfigFileService, ConfigFileService>();
|
||||
|
||||
// Platform Services
|
||||
services.AddSingleton<IDialogService>(sp =>
|
||||
new AvaloniaDialogService(GetMainWindow));
|
||||
|
||||
// ViewModels
|
||||
services.AddTransient<MainWindowViewModel>();
|
||||
}
|
||||
|
||||
private Window? GetMainWindow()
|
||||
{
|
||||
return (ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user