There is not a method to register a Singleton object?

Feb 13, 2008 at 8:39 PM
When I have to register un singleton, I have to call two methods for that?
Example:
_container = new UnityContainer();
_container.Register<ISingletonInterface, SingletonObject>();
_container.SetSingleton<SingletonObject>();

There is not just one call? something like that:
_container.Register<ISingletonInterface, SingletonObject>(true); // bool if this will be singleton

Feb 13, 2008 at 9:20 PM
Yes. However, you can chain the calls together:

_container.Register<ISingletonInterface, SingletonObject>().SetSingleton(SingletonObject>();