using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.DependencyInjection; namespace Toolkit.Foundation; public class HandlerInitialization(IServiceProvider provider) : IInitialization where THandler : class, IHandler where TMessage : class { public void Initialize() => StrongReferenceMessenger.Default.Register>(provider, (provider, args) => args.Reply(provider.GetRequiredService().Handle(args.Message))); } public class HandlerInitialization(IServiceProvider provider) : IInitialization where THandler : class, IHandler where TMessage : class { public void Initialize() => StrongReferenceMessenger.Default.Register(provider, (provider, args) => provider.GetRequiredService().Handle(args)); } public class HandlerKeyedInitialization(string key, IServiceProvider provider) : IInitialization where THandler : class, IHandler where TMessage : class { public void Initialize() => StrongReferenceMessenger.Default.Register(provider, key, (provider, args) => provider.GetRequiredKeyedService(key).Handle(args)); }