Table of Contents

Class NotificationHandlersExtension

Namespace
Arc4u.Dispatcher.Notification
Assembly
Arc4u.Dispatcher.dll

Extension method to register the notification handler collections (INotificationHandlers<T> and its overloads with up to five type arguments).

public static class NotificationHandlersExtension
Inheritance
NotificationHandlersExtension
Inherited Members

Examples

Registration:

services.AddNotificationHandlersAsScoped();

// Register the handlers.
services.AddScoped<INotificationHandler<Order>, AuditOrderHandler>();

Publishing:

public class OrderService(INotificationHandlers<Order> handlers)
{
    public Task PlaceAsync(Order order, CancellationToken cancellationToken)
        => handlers.PublishWhenAllAsync(order, cancellationToken);
}

Methods

AddNotificationHandlersAsScoped(IServiceCollection)

Register notification handlers to used to publish notifications as Scoped.

public static void AddNotificationHandlersAsScoped(this IServiceCollection services)

Parameters

services IServiceCollection

IServiceCollection

AddNotificationHandlersAsTransient(IServiceCollection)

Register notification handlers to used to publish notifications as Transient

public static void AddNotificationHandlersAsTransient(this IServiceCollection services)

Parameters

services IServiceCollection

IServiceCollection