c# - Passing resolving container to a resolved type -
i using unity.mvc3 , unity.wcf. using these packages, register types parent container, controllers / services created child container. types registered hierarchicallifetimemanager limited 1 instance per request.
i running issue classes take iunitycontainer constructor parameter. register these this.
container.registertype<ifoo, foo>(new injectionconstructor(container)); this causes foo created reference parent container, not child container. if resolve type registered hierarchicallifetimemanager, second instance. additionally, instance not disposed child container.
is there way register types such receive child container used resolve them?
if object has dependency of type iunitycontainer, it'll automatically injected resolving container. don't need configure anything, it'll work.
Comments
Post a Comment