Rants, rambles, news and notes from another geek

Enterprise Library and Object Builder

While finally catching up on blogs I read, I ran across Brian Buttons recent post titled Enterprise Library and Object Builder. Whether you are using CAB, EntLib or Object Builder directly you should go read his post, as it is full of all kinds of nuggets. For example:

The way OB can tell whether or not to treat an instance of a singleton or not is through ObjectBuilder concepts called Locators and LifetimeContainers. LifetimeContainers, in OB-speak, manage the lifetime of named instances of objects. You can register an object and its name with a LifetimeContainer, and it will keep that object alive until such time as you dispose of the LifetimeContainer. And every LifetimeContainer is associated with a Locator. A Locator acts as a dictionary that maps instance names to objects, but it does it using WeakReferences – this means that storing something in a Locator will not prevent that object from being GCed. Tot keep an object alive, you need to provide the LifetimeContainer as well, which is what keeps the references in use, preventing the object from being scavenging out of existence.

Good stuff.