コード例 #1
0
 /// <summary>
 /// Add delegate of <see cref="NotificationDelegateAsync{TRequest}"/> to the services collection.
 /// </summary>
 /// <typeparam name="TNotification">The request type</typeparam>
 /// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
 /// <param name="notificationDelegate">The instance of the publish processing delegate.</param>
 /// <param name="servicingOrder">The order of the processing.</param>
 /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns>
 public static IServiceCollection AddNotificationProcessingHandler <TNotification>(this IServiceCollection services, NotificationDelegateAsync <TNotification> notificationDelegate, ServicingOrder servicingOrder = ServicingOrder.Processing) where TNotification : class
 {
     if (notificationDelegate == null)
     {
         throw new ArgumentNullException(nameof(notificationDelegate));
     }
     services.AddSingleton <INotificationHandler <TNotification> >(new NotificationHandlerProcessingWrapper <TNotification>(notificationDelegate, servicingOrder));
     return(services);
 }
コード例 #2
0
 /// <summary>
 /// Constructs the wrapper class.
 /// </summary>
 /// <param name="notificationDelegate">The processing delegate.</param>
 /// <param name="servicingOrder">The processing priority.</param>
 public NotificationHandlerProcessingWrapper(NotificationDelegateAsync <TNotification> notificationDelegate, ServicingOrder servicingOrder = ServicingOrder.Processing)
 {
     _delegate       = notificationDelegate ?? throw new ArgumentNullException(nameof(notificationDelegate));
     OrderInTheGroup = servicingOrder;
 }