Restored the separation between message and generic dialog service in the service registration code

This commit is contained in:
Markus Ewald 2025-07-05 21:10:56 +02:00
parent bc2d288bbb
commit 61a8ac1e6f

View File

@ -34,9 +34,8 @@ namespace Nuclex.Avalonia.DependencyInjection {
/// <returns>The service collection for method chaining</returns> /// <returns>The service collection for method chaining</returns>
public static IServiceCollection AddMvvm(this IServiceCollection services) { public static IServiceCollection AddMvvm(this IServiceCollection services) {
// Allow displaying message boxes via the AvaloniaMessagePresenter which wraps // Use the convention-over-configuration binder as the default auto binder
// the MessageBox.Avalonia library services.AddSingleton<IAutoBinder, ConventionBinder>();
services.AddSingleton<IMessageService, AvaloniaMessagePresenter>();
// The window manager keeps track of which Window is in the foreground // The window manager keeps track of which Window is in the foreground
// and handles opening modal or modeless windows for which it either // and handles opening modal or modeless windows for which it either
@ -68,10 +67,10 @@ namespace Nuclex.Avalonia.DependencyInjection {
/// <summary>Registers all MVVM supporting services for a WinForms application</summary> /// <summary>Registers all MVVM supporting services for a WinForms application</summary>
/// <param name="services">Service collection the services will be registered to</param> /// <param name="services">Service collection the services will be registered to</param>
/// <returns>The service collection for method chaining</returns> /// <returns>The service collection for method chaining</returns>
public static IServiceCollection AddCommonDialogs(this IServiceCollection services) { public static IServiceCollection AddMessageDisplay(this IServiceCollection services) {
// Implementation of the message service that uses plain MessageBoxes // Allow displaying message boxes via the AvaloniaMessagePresenter which wraps
// from the Win32 API to display messages to the user // the MessageBox.Avalonia library
services.AddSingleton<IMessageService, AvaloniaMessagePresenter>(); services.AddSingleton<IMessageService, AvaloniaMessagePresenter>();
return services; return services;