using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.DependencyInjection; namespace Toolkit.Foundation; public class AsyncHandlerInitialization(IServiceProvider provider) : IInitialization where THandler : class, IAsyncHandler where TMessage : class { public void Initialize() => WeakReferenceMessenger.Default.Register>(provider, async (provider, args) => args.Reply(await provider.GetRequiredService().Handle(args.Message, args.CancellationToken))); } public class AsyncHandlerInitialization(IServiceProvider provider) : IInitialization where THandler : class, IAsyncHandler where TMessage : class { public void Initialize() => WeakReferenceMessenger.Default.Register>(provider, async (provider, args) => await provider.GetRequiredService().Handle(args.Message, args.CancellationToken)); }