Register handlers manually? #799
Unanswered
SebastianStehle
asked this question in
Q&A
Replies: 1 comment
-
|
MediatR does not care about DI registration. It only resolves using a container. You do whatever you need to do to register types (there are samples in this repo). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am actually migrating a project to mediatr, because I would like to leverage the pipeline.
My project has an existing command structure already, but implemented in services: https://github.com/notifo-io/notifo/blob/main/backend/src/Notifo.Domain/Apps/IAppStore.cs#L29
I thought I can just implement the handler interface instead: https://github.com/notifo-io/notifo/blob/mediatr/backend/src/Notifo.Domain/Apps/AppStore.cs#L115
But I have no idea how to register this type. When I register as
IRequestHandler<AppCommand, App?>interface it does not get discovered.I guess I could add a separate command handler, but this would actually just create more code and I do not see the advantage yet. I would have to keep the upsert method in my IAppStore and just have an wrapper over it.
I user the normal assembly scanning process I would have duplicate instances.
Beta Was this translation helpful? Give feedback.
All reactions