Unity Container

Unity container is an open source IoC container for .NET applications supported by Microsoft. It is a lightweight and extensible IoC container.

The source code for Unity container is available at https://github.com/unitycontainer/unity.

Unity Container Features:

  • Simplified type-mapping registration for interface type or base type.
  • Supports registration of an existing instance.
  • Supports code-based registration as well as design time registration.
  • Automatically injects registered type at runtime through a constructor, a property or a method.
  • Supports deferred resolution.
  • Supports nested containers.
  • Automatic disposing of instances based on lifetime managers; lifetime managers include hierarchical, per resolve, externally controlled, per request and per thread.
  • Supports service location capability; this allows clients to store or cache the container.
  • Supports type interception and instance interception.
  • Easy to extend.

Before we start working with the Unity container, let's learn how to install it, in the next chapter.