Closed Atulin closed 7 months ago
In MediatR
one could register it by manually registering handler:
services.AddSingleton<IRequestHandler<Command<Story>, ActionResult>, Handler<Story>>();
But it doesn't seem to work in Mediator
I'm still getting the error about handler not being found error.
True, doesn't support generic messages yet. Will require a refactoring of some things so not sure that will possible. I double checked, and it is documented in the "differences from MediatR" section in the readme: https://github.com/martinothamar/Mediator?tab=readme-ov-file#6-differences-from-mediatr
There is no support for manually registering message handlers, might be possible to change though, by checking the service collection before registering, though there may be more issues down the road..
The fundamental issue is that the sourcegen'd implementation is based around knowing concrete types, underlying handling functions need to namethem (it's not simply message.GetType()
)
Closing this and keeping track of #76
I switched from MediatR to Mediator recently, for sourcegen instead of reflections. Alas, it doesn't seem to support generic handlers, and I have a specific use case for them: