adova
adova

Reputation: 1040

Register Pipeline Behavior with 3 Type Arguments

With Mediatr 9, I am trying to register a pipeline behavior that takes an additional type argument. While it does compile, the pipeline is not getting hit.

Validation Pipeline Signature:

public class EnvelopeValidationHandlerAsync<TRequest, TResponse, TRequestItem> : IPipelineBehavior<TRequest, TResponse>        
        where TRequest : RequestEnvelope<TRequestItem, Response<TResponse>>
        where TRequestItem : RequestItem, new()
        where TResponse: class

Request Signature:

public class CreatePatientRequestEnvelope: RequestEnvelope<CreatePatientRequest, Response<PatientResponse>>

public class CreatePatientRequest : RequestItem

Request Envelope:

 public class RequestEnvelope<TRequestItem, TResponse> : Request<TResponse>, IRequestEnvelope<TRequestItem, TResponse>
        where TRequestItem : IRequestItem, new()

Using Autofac, I am registering as:

containerBuilder.RegisterGeneric(typeof(EnvelopeValidationHandlerAsync<,,>)).As(typeof(IPipelineBehavior<,>));

Upvotes: 1

Views: 45

Answers (0)

Related Questions