Unity Application Block 1.2 - October 2008

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.

patterns & practices Developer Center

patterns & practices Developer Center

December 2008

Summary

The Unity Application Block (Unity) is a lightweight, extensible dependency injection container with optional support for instance and type interception.

Downloads

Unity Application Block 1.2 - October 2008
Unity Application Block 1.2 Documentation for Visual Studio 2008
Unity Application Block 1.2 Documentation for Visual Studio 2005

Class Library

Unity Application Block 1.2 Class Library on MSDN

Hands-On Labs

Hands-on Labs for the Unity Application Block 1.2

Webcasts

Introduction to dependency injection with Unity, (demo code)

Extending the Unity dependency injection container, (demo code)

Community

https://www.codeplex.com/unity

License

End User Licensing Agreement (EULA)

Contents

Overview
What's New
Getting Started
Community
Feedback and Support
Authors and Contributors
Related Titles

Overview

The Unity Application Block (Unity) is a lightweight, extensible dependency injection container. It facilitates building loosely coupled applications and provides developers with the following advantages:

  • Simplified object creation, especially for hierarchical object structures and dependencies
  • Abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns
  • Increased flexibility by deferring component configuration to the container
  • Service location capability; this allows clients to store or cache the container
  • Instance and type interception (via an extension introduced in this release)

Introduction to Unity includes a series of brief sections that provide information that will help you decide whether the Unity Application Block is suitable for your requirements.

Developing Applications Using Unity describes how to configure the container to perform particular tasks and explains how to use Unity to create and build instances of objects.

Using Interception with Unity describes how to declare which methods are intercepted (matching rules), how they get intercepted (interceptors) and what happens when a method is intercepted (call handlers).

To learn how to add functionality, see Extending and Modifying the Unity Application Block.

For details on deployment, see Deployment and Operations.

Common Scenarios

Each scenario explains the task, describes a real-world situation where such a task might arise, and includes code demonstrating how to use the Unity Application Block to complete the task. The scenarios are as follows:

Audience Requirements

A working knowledge of .NET programming is required.

System Requirements

The following are the minimum system requirements for Unity:

  • Microsoft Windows XP Professional, Windows Server 2003, Windows Server 2008, or Windows Vista operating system
  • Microsoft .NET Framework 2.0, 3.0, 3.5, or 3.5 SP1
  • Microsoft Visual Studio 2005, Visual Studio 2008, or Visual Studio 2008 Service Pack 1 development system (any of the following editions):
    • Standard Edition
    • Professional Edition
    • Team Edition for Software Developers
    • Team Edition for Software Testers
    • Team Edition for Software Architects
    • Team Suite

The Unity Application Block solution and project files are all in Visual Studio 2005 format, and you can open and modify them using Visual Studio 2005. The binary assemblies provided with the application block are targeted at version 2.0 of the .NET Framework. However, you can use the Unity Application Block in applications created with Visual Studio 2008 by setting a reference to the binary assemblies.

You can modify or extend the Unity Application Block using Visual Studio 2008. When you open a solution, Visual Studio 2008 will upgrade the projects to its format and you can edit and compile the code to create assemblies targeted at version 3.5 of the .NET Framework. However, you will not be able to convert the projects back into Visual Studio 2005 format. Therefore, it is a good idea to work with a copy of the original solutions and projects.

Design Goals

The Unity Application Block was designed to achieve the following goals:

  • To promote the principles of modular design through aggressive decoupling
  • To raise awareness of the need to maximize testability when designing applications
  • To provide a fast and lightweight dependency injection container mechanism for creating new object instances and managing existing object instances
  • To expose a compact and intuitive API for developers to work with the container
  • To support a wide range of code languages, with method overrides that accept generic parameters where the language supports these
  • To implement attribute-driven injection for constructors, property setters, and methods of target objects
  • To provide extensibility through custom and third-party container extensions
  • To provide the performance required in enterprise-level line-of-business (LOB) applications

For more information about the design of Unity, see the section Design of the Unity Application Block.

What's New

The Unity Application Block 1.2 release contains the following changes to the previous release (Unity 1.1 – May 2008):

  • Added an interception mechanism (extension) and integration of the Policy Injection Application Block with the Unity Application Block.
  • Added two instance interceptors (TransparentProxyInterceptor, InterfaceInterceptor) and one type interceptor (VirtualMethodInterceptor).
  • Improved support for generics.
  • Added support for arrays.
  • Registered names are now available as an ObjectBuilder policy so that you can do a ResolveAll from within the strategy chain. The container automatically registers itself with itself.
  • Added PerThreadLifeTimeManager.
  • Bug fixes.
  • Performance improvements.

Getting Started

For an introduction to dependency injection, see the article Inversion of Control Containers and the Dependency Injection pattern by Martin Fowler.

For information about the key features of the Unity Application Block, see Unity QuickStarts. This topic demonstrates some of the key features of Unity and is a good starting point for working with Unity.

You can also use the Hands-on Labs to practice Unity application block capabilities in various contexts. The Hands-On Labs are a separate download:

Community

The Unity Application Block, like many patterns & practices deliverables, is associated with a community site. On this community site, you can post questions, provide feedback, or connect with other users for sharing ideas. Community members can also help Microsoft plan and test future releases of Unity, and download additional content such as extensions and training material.

Feedback and Support

Questions? Comments? Suggestions? To provide feedback about the Unity Application Block, or to get help with any problems, visit the Unity Community site. The message board on the community site is the preferred feedback and support channel because it allows you to share your ideas, questions, and solutions with the entire community. The Unity Application Block is a guidance offering, designed to be reused, customized, and extended. Code-based guidance is shipped "as is" and without warranties. Customers can obtain support through Microsoft Premier Support Services for a fee, but the code is considered user-written by Microsoft support staff.

Authors and Contributors

The Unity Application Block was produced by the following individuals:

  • Product/Program Management: Grigori Melnik (Microsoft Corporation)
  • Architecture/Development: Chris Tavares (Microsoft Corporation) and Fernando Simonazzi (Clarius Consulting)
  • Testing: Erik Renaud (nVentive Inc), Vijaya Janakiraman (Solutions IQ), Hanz Zhang and Carlos Farre (Microsoft Corporation)
  • Documentation: Dennis DeWitt (Linda Werner & Associates Inc) and Alex Homer (Microsoft Corporation)
  • Editing and release: Nelly Delgado and RoAnn Corbisier (Microsoft Corporation), Tina Burden McGrayne (TinaTech, Inc.), and Richard Burte (ChannelCatalyst.com, Inc.)

Special thanks to the members of the Industry Advisory Board:

  • Brian Button (Asynchrony Solutions)
  • Daniel Piessens (Red Prairie)
  • Francois Tanguay (nVentive)
  • Keenan Newton (Microsoft Corporation)
  • Kyle Huntley (Avanade)
  • Lenny Fenster (Microsoft Corporation)
  • Rinat Shagisultanov (Neudesic)
  • Tom Hollander (Microsoft Corporation)

Many thanks to the following people who previewed Unity and provided meaningful feedback:

  • Ade Miller, Blaine Wastell, Bob Brumfield, Brad Wilson, Dmitri Ossipov, Don Smith, Francis Cheung, Glenn Block, Michael Puleio, Mohammad Al-Sabt, Jason Hogg, and Junfeng Zhang (Microsoft Corporation), and Francois Tanguay (nVentive).

Related Titles

patterns & practices Developer Center