Closed eglauko closed 5 years ago
@eglauko That's not correct but I believe I know why it happens. There is a short cut when it comes to SingletonPerScope which must not be taking into account keyed resolution. I'll look at fixing it this weekend.
OK I've addressed this issue. It turned out to be the dependency was being pulled accidentally from the injection scope as a last ditch effort to find something that matched. I've since tightened up the code a little bit and the test now passes.
When I need different implementations of the same interface, I use qualifiers, AsKeyed, when I configure the services. If I have a class with a property to be injected with a key, and not required, no error occurs and the property value will be null. Is this right.
Take a look in my test, there is no service for 'gama' key.
This test passes. But if I change the lifestyle of one of the services to SingletonPerScope, the test fails. The Gamma property will be assigned with the class that is configured with SingletonPerScope.
c.Export<AlphaNameService>().AsKeyed<INameService>("Alpha").Lifestyle.SingletonPerScope();
take a try