MediatR: Generic Request
Aug 22, 2021
Sometimes, when we use MediatR, we need to use generic request. But, MediatR can’t find the required handler because default implementation of ServiceFactory
get service by using type IRequestHandler<TRequest, THandler>
.
To solve this, we need to create custom ServiceFactory
for MediatR. Custom service type converter should implement IMediatorServiceTypeConverter
.
For code usage example, we use Microsoft.Extensions.DependencyInjection