This is a follow up to my previous post. I deliberately didn’t discuss the issues that arise when using container hierarchies to get some feedback on usage first.
So what’s the problem?
Consider trivial scenario:
We have two components, where foo depends on bar. The dependency is optional, which means that foo can be constructed even when bar is not available.
Then we have the following container hierarchy:
We have parent container where foo is registered and two child containers. In one of them we register bar. Both foo and bar are singletons (for sake of simplicity – the example would work for any non-transient lifestyle).
Now we do this
What should happen?