Export (0) Print
Expand All

Creating Lifetime Managers

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Unity Application Block information can be found at the Unity Application Block site.

The Unity Application Block supports two separate approaches for registering singleton objects and instances of existing objects. You can use the RegisterType and RegisterInstance methods to register object instances with the default lifetime. Alternatively, you can specify an instance of a lifetime manager with these methods to provide a more granular control of the lifetime of the registered object. For more details of the methods for registering types and instances of existing objects, see Unity Application Block Methods.

The RegisterType and RegisterInstance methods accept an instance of the LifetimeManager class. This class controls the lifetime of objects that you register. By default, the Unity Application Block provides three LifetimeManager classes that you can use. For details of these, see Using Lifetime Managers.

You can also create custom LifetimeManager classes if you require additional functionality not available in the default classes. Documentation to help you do this is available from the Unity Community Web site on CodePlex.

© 2014 Microsoft