I have code similar to this:
class A: IA { ... }
class B: IB {
public B(IA a, ...) { ... }
...
}
class C1 {
public C1(IA a, IB b, ...) { ... }
}
class C2 {
public C2(IA a, IB b, ...) { ... }
}
What I want is only two instances of A -- one to go with C1 and one to go with C2. I want two instances of B. The instance of B passed to C1 should get the same instance of A created for C1. C2 and his parameters should have a different instance of A. How can I configure this scenario in Autofac? It looked like the Owned instance lifetime feature was supposed to handle this, but the posted example was only one layer deep, not two.
My real situation is much more complex. I have a dozen inheritors of IB and a half dozen C defs that take various combinations of the IB inheritors. I wanted to avoid using the named instances because that would bloat my bootstrapper significantly and make it difficult to maintain.
Secondary question: does DryIoc support this? I could be talked into switching.