Upgrading from 3.5 to 5.11. ContainerControlledLifetimeManager seems not to work as before
Closed this issue · 2 comments
Hi,
In my code I want a class implementing multiple interfaces as a singleton, no matter which Interface is used to resolve it.
This is the code that worked without out issues before:
Registering my component:
container.RegisterType<IRunableComponent, LoadCycleManager>(ComponentNames.LoadCycleManager, new ContainerControlledLifetimeManager()); container.RegisterType<IEbc, LoadCycleManager>(ComponentNames.LoadCycleManager, new ContainerControlledLifetimeManager()); container.RegisterType<ILoadCycleManager, LoadCycleManager>(ComponentNames.LoadCycleManager, new ContainerControlledLifetimeManager());
Resolving it as IEbc:
var components = container.ResolveAll<IEbc>().ToList();
with ResolveAll constructor of LoadCycleManager is called
Resolving it as IRunableComponent:
var components = container.ResolveAll<IRunableComponent>().ToList();
with ResolveAll constructor of LoadCycleManager is called again
Is this a issue, or has the way how to register a class for multiple interfaces changed?
Thanks for your help
Rainer
You need to register your type as singleton and register each interface as a mapping to it.
http://unitycontainer.org/articles/changelog.html
Thank you for your Help :-)
Problem is solved.
Regards
Rainer