container
container copied to clipboard
Registration at ChildContainer with other LifetimeManager
I have a problem with migration from MicrosoftPractices.Unity to Unity 5.10.3.
I use construction like this, to change LifeTimeManager of already registered in parentContainer types.
var parentContainer = _unityContainer;
_unityContainer = _unityContainer.CreateChildContainer();
foreach (var registration in parentContainer.Registrations)
{
if (registration.LifetimeManager is ContainerControlledLifetimeManager || registration.RegisteredType == typeof(IUnityContainer))
{
continue;
}
_unityContainer.RegisterType(registration.RegisteredType, registration.MappedToType, new ContainerControlledLifetimeManager());
}
At parentContainer they are registered with PerResolveLifetimeManager, but at childContaner it should be ContainerControlledLifetimeManager.
It used to work at old version, but now childContainer cannot resolve types registered with RegisterFactory method at parentContainer.
I would need a test case demonstrating the problem.