Singleton builder example

Jul 19, 2006 at 1:35 AM
Anybody got an example of using a Singleton policy with OB? I created a Builder, Locator and added the Singleton policy but nothing happened. I'm not sure what (if anything) I have to do with the locator.
Jul 19, 2006 at 2:10 PM
One of the really non-obvious things in OB 1.0 is that the lifetime container that is used must be "found" in the locator. So the typical setup code looks like:

ReadWriteLocator locator = new ReadWriteLocator();
LifetimeContainer container = new LifetimeContainer();
locator.Add(typeof(ILifetimeContainer), container);

If the singleton strategy doesn't find the lifetime container in the locator, then it essentially no-ops.