Unity IoC - February 26 Weekly Drop - LifetimeManagers TearDown Extensions and IDisposable
The new Unity IoC / Dependency Injection Container from Microsoft Patterns & Practices has a number of new features in the February 26th Weekly Drop. As menetioned on CodePlex:
- SetLifetime method allows you to specify a LifetimeManager object for a particular dependency. LifetimeManagers are included for the existing singleton and instance lifestyles, and it's easy to write your own. This provides the underlying support needed to implement per-ASP.NET-request semantics, for example.
The current SetSingleton and RegisterInstance APIs are still available; internally they now use a LifetimeManager.
- Teardown: The opposite of BuildUp, the container now has a Teardown method which objects can be run through to shut down / clean up / whatever you want. The existing container behavior does nothing at Teardown time, but extensions can be written to take advantage of this.
- Extensions can implement IDisposable: If an extension object implements IDisposable, it now gets disposed when the container does.
Download the February 26th weekly release.
Tags:
DependencyInjection,
IoC,
Unity