Add an endpoint that supports generics
This will be slightly faster than using reflection to figure out the request type.
But the calling signature has to be explicit in defining the <message,response>
// without generics
var result = await mediator.HandleAsync(simpleQuery, context);
// with generics
var result = await mediator.HandleAsync<SimpleQuery, SimpleResponse>(simpleQuery, context);
I agree that specifying generic parameters explicitly is not good. Do you know what kind of constraints MediatR has in place so it magically works?
I agree that specifying generic parameters explicitly is not good. Do you know what kind of constraints MediatR has in place so it magically works?
It doesn't use generics to define the TRequest like my first method. Hence doesn't require explicit specifying when called.
https://github.com/jbogard/MediatR/blob/master/src/MediatR/Mediator.cs