Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a single instance of the Unity container?

Sorry for this noob question. I'm beginning to use the Unity 2.0 container with Silverlight and am putting some singletons in it. For the singletons to work, do I need to have just one instance of the container in my application? I assume that making a new unity container instance whenever I want to look up my singletons will result in separate containers with separate singletons.

Thanks, -Jon

like image 959
Jon Onstott Avatar asked Dec 01 '22 03:12

Jon Onstott


1 Answers

You need a single instance of a container to achieve singleton behaviour. Also you need to register your singleton classes with ContainerControlledLifetimeManager.

like image 51
George Polevoy Avatar answered Dec 03 '22 19:12

George Polevoy