/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Consumers/Configuration/ObserverPipeSpecification.cs
34 строки
982 B
Chris Patterson
Integration of all external packages into MassTransit, split out into Abstractions, Middleware, and the core MassTransit assembly.
22 янв 2022, 18:24
22 янв 2022, 18:24
b5b4f50
Код
Авторство
О чём код?
namespace MassTransit.Configuration { using System; using System.Collections.Generic; using Middleware; /// <summary> /// Adds a message handler to the consuming pipe builder /// </summary> /// <typeparam name="T">The message type</typeparam> public class ObserverPipeSpecification<T> : IPipeSpecification<ConsumeContext<T>> where T : class { readonly IObserver<ConsumeContext<T>> _observer; public ObserverPipeSpecification(IObserver<ConsumeContext<T>> observer) { _observer = observer; } void IPipeSpecification<ConsumeContext<T>>.Apply(IPipeBuilder<ConsumeContext<T>> builder) { builder.AddFilter(new ObserverMessageFilter<T>(_observer)); } IEnumerable<ValidationResult> ISpecification.Validate() { if (_observer == null) yield return this.Failure("Handler", "must not be null"); } } }