Compartir a través de


Unity Application Block 1.1 - May 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.

Unity Application Block

For the latest information on the Unity Application Block, see https://msdn.microsoft.com/en-us/library/dd203101.aspx

patterns & practices Developer Center

patterns & practices Developer Center

May 2008

Summary

The Unity Application Block (Unity) is a lightweight, extensible dependency injection container.

Downloads

Unity Application Block 1.1 – May 2008
Unity Application Block Documentation for Visual Studio 2008
Unity Application Block Documentation for Visual Studio 2005

Webcasts

Introduction to dependency injection with Unity, (demo code)

Extending the Unity dependency injection container, (demo code)

Community

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

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.

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, or 3.5
  • Microsoft Visual Studio 2005 or Visual Studio 2008 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

This release of the Unity Application Block contains several minor changes to the source code of the previous release (Unity 1.0 – April 2008). These changes include the following:

  • Removal of all obsolete ObjectBuilder code.
  • Fix for a bug when using lifetime managers with open generic types.
  • Fix for a bug where the RegisterType method was overriding the RegisterInstance method.
  • Performance improvement when resolving singletons.
  • Exposure of some additional internal classes as public to make it easier write extensions that need to resolve dependencies in a customized way.
  • Addition of try...catch blocks to improve the error messages returned when value resolution fails.

These changes do not affect the API of Unity, or the way that you use it.

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.

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 Management: Grigori Melnik (Microsoft Corporation)
  • Program Management: Scott Densmore and William Loeffler (Microsoft Corporation)
  • Architect: Chris Tavares (Microsoft Corporation)
  • Development: Chris Tavares (Microsoft Corporation), Fernando Simonazzi (Clarius Consulting), and Nicolas Botto (Digit Factory)
  • Test team: Hanz Zhang and Carlos Farre (Microsoft Corporation); Naveen Guda, Pooja Parate, Pravin Pawar, Ronita Acharya, Sai Pasumarthi, and Venkata Appaji Sirangi (Tata Consultancy Services); and Vijaya Janakiraman (Solutions IQ)
  • Documentation: Alex Homer (Content Master Ltd);
  • Edit team: Nelly Delgado and RoAnn Corbisier (Microsoft Corporation), Tina Burden McGrayne (TinaTech, 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, Don Smith, Glenn Block, Michael Puleio, Francis Cheung (Microsoft Corporation)

Related Titles

patterns & practices Developer Center

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.

Unity Application Block

For the latest information on the Unity Application Block, see https://msdn.microsoft.com/en-us/library/dd203101.aspx