khellang / Scrutor

Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection
MIT License
3.58k stars 234 forks source link

Register up to one implementation with marker interface #164

Open Alan1616 opened 2 years ago

Alan1616 commented 2 years ago

I want to do the following

 scan => scan
               .FromAssemblies(assembly)
               .AddClasses(classes => classes.AssignableTo<IScopedService>())
               .UsingRegistrationStrategy(RegistrationStrategy.Throw)
               .AsSelfWithInterfaces()
               .WithScopedLifetime()

But it would always throw as i have many IScopedService in my assembly. Let's say i have class A : InterfaceA, IScopedService and class B: InterfaceA, IScopedService only then it should throw. Is this possible with scrutor?

khellang commented 2 years ago

Hi @Alan1616! 👋🏻

Sorry for the long response time! I'm not sure what your desired scenario is here. Do you want it to throw or not? 😅