jbogard / MediatR.Extensions.Microsoft.DependencyInjection

MediatR extensions for Microsoft.Extensions.DependencyInjection
MIT License
326 stars 90 forks source link

DI using types doesn't seem to work as intented #122

Closed rainier-bacareza closed 2 years ago

rainier-bacareza commented 2 years ago

Hi,

So we have a console application that is dependent on 2 Projects, these 2 projects contains Handlers that we wanted to be injected but not all, and some comes from console app. However when we tried to inject the handler (types) inside the Console App, the DI seems to scan every handler in its dependent causing a unresolvable dependencies.

We have fixed the issue by using "WithEvaluator" method. Below is our sample code.

image

jbogard commented 2 years ago

It's not "seems to", that's exactly the point of this library. If you only want specific handlers to be registered, I wouldn't use this library at all. Just manually register your types so you don't have the assembly scanning.