Title: Add non-generic PublishAsync(INotification) overload for runtime-typed notifications
Labels: enhancement, mediator
Body:
Problem
IMediator.PublishAsync<TNotification> requires the notification type to be known at compile time. There is no runtime-dispatch overload like:
Task PublishAsync(INotification notification, CancellationToken cancellationToken = default);
This makes it impossible to publish notifications when the concrete type is determined at runtime (e.g., deserializing events from a message bus, dispatching domain events from an aggregate root's List<INotification>).
Commands and queries already have this pattern (SendCommandAsync(ICommand<TResult>) and SendQueryAsync(IQuery<TResult>) use reflection-based dispatch).
Proposed Solution
Add to IMediator:
Task PublishAsync(INotification notification, CancellationToken cancellationToken = default);
Implementation in Mediator.cs should follow the same reflection + ConcurrentDictionary<Type, MethodInfo> caching pattern used for commands and queries.
Title: Add non-generic
PublishAsync(INotification)overload for runtime-typed notificationsLabels:
enhancement,mediatorBody:
Problem
IMediator.PublishAsync<TNotification>requires the notification type to be known at compile time. There is no runtime-dispatch overload like:This makes it impossible to publish notifications when the concrete type is determined at runtime (e.g., deserializing events from a message bus, dispatching domain events from an aggregate root's
List<INotification>).Commands and queries already have this pattern (
SendCommandAsync(ICommand<TResult>)andSendQueryAsync(IQuery<TResult>)use reflection-based dispatch).Proposed Solution
Add to
IMediator:Implementation in
Mediator.csshould follow the same reflection +ConcurrentDictionary<Type, MethodInfo>caching pattern used for commands and queries.