Unity and ChildContainers

Oct 5, 2009 at 5:22 PM


I am new to the Unity Framework. I have a core module that uses unity and it injects all default mappings. Like for example, I map ILogger to TextLogger. I have a module Module1 that uses core. However in this module, I want ILogger to be TraceLogger. How do I achieve this. When i am configuring this moduleA, I said, createChildContainer and I added teh trace logger to the child. How do I resolve teh child container in other classes.


Help appreciated


Dec 18, 2009 at 12:36 AM

I don't understand the question. Do you want to inject the child container directly into objects in the module, or do you want to use the child container to resolve objects in the module. For the second, well, you just do it. For the first, you just resolve through the child container, have dependencies on  IUnityContainer, and it should just work.