Scanning generics for mediatr handlers
See original GitHub issueHi. I have a generic mediatr request handler which looks like this:
public class GetOneByIdHandler<T> : IRequestHandler<GetOneByIdRequest<T>, T> where T : IBaseEntity
{
private readonly IAsyncRepository<T> _asyncRepository;
public GetOneByIdHandler(IAsyncRepository<T> asyncRepository)
{
_asyncRepository = asyncRepository;
}
public async Task<T> Handle(GetOneByIdRequest<T> request, CancellationToken cancellationToken)
{
return await _asyncRepository.GetOneByIdAsync(request.Id);
}
}
Right now I have to add the handler for every DTO manually. How can I automate this with Scrutor? Thanks!
services.AddTransient<IRequestHandler<GetOneByIdRequest<MyDto>, MyDto>, GetOneByIdHandler<MyDto>>();
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
c# - MediatR generic handlers
I use a MediatR library in my Asp .Net core 6 app. And I have a the same logic for a group of...
Read more >How to register open-generic types (Command and ...
I'm building the app and trying to implement Domain Events with MediatR. I am on .NET Core 6 (preview, but I do not...
Read more >You Probably Don't Need to Worry About MediatR
Actually, no, it's never used as a service locator. No one uses the IMediator interface to locate services. They use it to dispatch...
Read more >MediatR and StructureMap–Using Generic ...
I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website...
Read more >CQRS and MediatR in ASP.NET Core
How to use the MediatR NuGet library in ASP.NET Core, and working with the CQRS and Mediator architectural patterns.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@julealgon unfortunately my case is not related to MediatR only, but to custom services also, one of which is provided in the example.
any update? eg: ConcreteClass<T>:IConcrete<Foo< T >,T>