Udostępnij za pośrednictwem


Unity 3 – April 2013

patterns & practices Developer Center

On this page: Download:
Summary | Overview - Audience Requirements, Contents of This Release, System Requirements, Design Goals | What's New | Getting Started | Community | Feedback and Support | Authors and Contributors | Related Titles

Download code

Download PDF File

Order paperback

patterns & practices Developer Center

April 2013

Summary

Unity is a lightweight, extensible dependency injection container with support for instance and type interception.

Downloads

Via NuGet (inside Visual Studio, use the NuGet package manager and search for “unity”)

Microsoft Unity Application Block 3
Microsoft Unity Application Block 3 Documentation

Release Notes

Release Notes

Developer's Guide

Code samples

Developer’s Guide to Dependency Injection using Unity (MSDN)

Developer’s Guide to Dependency Injection using Unity (PDF, EPUB)

Developer’s Guide to Dependency Injection using Unity (MOBI)

Order Book

Developer’s Guide to Dependency Injection using Unity is available in paperback from Amazon.com

QuickStarts

Unity QuickStarts

Hands-on Labs

Hands-on Labs for Unity 3

Class Library

Unity 3 Class Library on MSDN

Support

Discussions for patterns & practices – Unity

Community

patterns & practices Enterprise Library Community Site

Feedback & Issue Reporting

Issue Tracker

License

Microsoft Public License (Ms-PL)

Overview

Unity is a lightweight, extensible dependency injection container with support for constructor, property, and method call injection. 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, which allows clients to store or cache the container.
  • Instance and type interception (not supported in Unity for Windows Store apps).

Unity is a general-purpose container for use in any type of Microsoft.NET Framework-based application. It provides all of the features commonly found in dependency injection mechanisms, including methods to register type mappings and object instances, resolve objects, manage object lifetimes, and inject dependent objects into the parameters of constructors and methods, and as the value of properties of objects it resolves.

In addition, Unity is extensible. You can write container extensions that change the behavior of the container, or add new capabilities. For example, the interception feature provided by Unity, which you can use to capture calls to objects and add additional functionality and policies to the target objects, is implemented as a container extension.

This release adds support for Windows Store apps as well as the registration by convention feature to ease the task of configuring Unity.

Audience Requirements

These reusable components and guidance are intended primarily for software developers and software architects. To get the most benefit from this guidance, you should a working knowledge of .NET programming.

Contents of This Release

Microsoft Unity 3 contains the following:

  • Binaries. The release includes pre-compiled, strong-named assemblies for all the source code.
  • Source code. The release includes the source code for the Unity container, the Unity Interception Mechanism, Unity configuration as well as the source code for the integration packages with ASP.NET MVC and ASP.NET Web API.
  • Unit tests. The release includes the unit tests that were created while Unity 3 was being developed.
  • Documentation. A separate download for Unity includes documentation, which includes guidance about how to use Unity and a class library reference.
  • Hands-on Labs. The Unity Hands-on Labs help you learn about the Unity injection container and Unity interception. Step by step instructions and before and after source code are provided for each lab.

System Requirements

  • Supported architectures: x86 and x64.
  • Operating systems: Microsoft Windows 8, Microsoft Windows 7, Windows Server 2008 R2, Windows Server 2012.
  • .NET Framework: Microsoft .NET Framework 4.5, .NET for Windows Store Apps (previously known as Windows Runtime)

For a rich development environment, the following are recommended:

  • Microsoft Visual Studio 2012 (Professional, Ultimate, or Express editions).

Design Goals

Unity was designed to achieve the following goals:

  • To promote the principles of modular design through aggressive decoupling of components, business objects, and services.
  • 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 use with the container.
  • To support a wide range of programming 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 line-of-business applications.

What's New

This major release of Unity includes the following new features:

  • Registration by convention.
  • Support for NetCore (Windows Store apps).
  • Resolving objects of type Lazy<T> by Unity.
  • The Unity assembly is now Security Transparent.
  • Support for ASP.NET MVC and ASP.NET Web API.

The detailed list of all changes is included in the Release Notes.

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 getting started with Unity, see the Unity documentation and the new Unity Developer’s Guide.

Community

Unity, 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 to share 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 Unity, 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. Unity 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 by Microsoft support staff as user-written.

Authors and Contributors

Unity 3 was produced by the following individuals:

- Product/Program Management: Grigori Melnik (Microsoft Corporation)
- Architecture/Development: Julian Dominguez (Microsoft Corporation), Fernando Simonazzi and Edgardo Rossetto (Clarius Consulting), Hernan de Lahitte (Digit Factory)
- Testing: Mani Subramanian (Microsoft Corporation), Mariano Grande (Digit Factory), Rathi Velusamy, Lavanya Selvaraj, and Shebu Kollam Valappil (Infosys Technologies Ltd.)
- Performance and Security Testing: Carlos Farre (Microsoft Corporation), Naveen Pitipornvivat and Soranai Chantarayotha (Adecco)
- Documentation: Dominic Betts (Content Master Ltd), Grigori Melnik and Mani Subramanian (Microsoft Corporation), and Fernando Simonazzi (Clarius Consulting)
- Graphic design: Chris Burns
- Editing, pre- and post-production: RoAnn Corbisier, Nelly Delgado, Handan Selamoglu, and Jane Sinyagina (Microsoft Corporation)
- Release management: Nelly Delgado and Grigori Melnik (Microsoft Corporation) and Richard Burte (Channel Catalyst, Inc)
- Business administration support: Kerstin Scott (Microsoft Corporation)

A special thanks to Microsoft colleagues who contributed many ideas and improvements of the Unity Application Block: Bob Brumfield (main contributor to porting Unity to .NET for Windows Store apps), Scott Densmore, Tyler Ohlsen, Chris Tavares, Andrew Oakley, and Hanz Zhang.

Unity 3 Advisory Board:
- Fabian Fernandez Bargas (TellMi)
- Joseph M. Blank (Online Business Systems)
- Bryan Clark (Ethos Solutions)
- Gabriele Giuseppini (Optiver Holding B.V.)
- Deon Heyns
- Matt Kean (Caterpillar Inc)
- Ercenk Keresteci and Trent Swanson (Full Scale 180, Inc.)
- Randy Levy
- Jeremy Likness (Wintellect)
- Andrei Marukovich (AB SCIEX)
- Ksenia Mukhortova (Intel)
- Peter Nilsson (Volvo Information Technology AB)
- Dan Piessens (Centare)
- Peter Ritchie (Peter Ritchie Inc.)
- Luke G. Sigler (Qualcomm Life)
- Jon Wagner (eMoney Advisor)
- Sebastian Weber
- Bill Wilder (DevPartners)
- Matias Woloski (Auth0)
- Walter Wu (Royal Bank of Canada)
- Nuno Centeno, Jason Hogg, Tom Hollander, Robert Jarratt, Michael Lanzetta, Valery Mizonov, Rafael Fernandez Moctezuma, Tyler Ohlsen, Timothy Stockstill, Christopher Tavares, Michael Thomassy, Rob Vettor (Microsoft Corporation)

Many thanks to the following people who reviewed our new guides and provided meaningful feedback:
- Garret Besser (Avanade)
- Thomas Mueller (CareSeed)
- Peter Ritchie
- Rob Jarratt
- Steven van Deursen (Cutting Edge Internet Technologies)
- Nicholas Blumhardt
- Chris Tavares, Alex Homer, and Tyler Ohlsen (Microsoft Corporation)

Additionally, we thank the following members of the community who commented on our initial vision and the product backlog: Damir Arh (Adacta), Jean-Luc Boucho (Infosys), Srđan Božović (MFC Mikrokomerc), Michael S. Collier (Aditi), Olivier Dahan (E-Naxos), Carlos dos Santos (CDS Informática), Christopher Maneu (Deezer), Paulo Morgado (C# MVP), Raffaele Rialdi (Vevy Europe), and Bruno Sonnino (Revolution Software)