Run-Time Configuration

This topic explores the techniques you can use to configure Unity containers using code that executes at run time and calls the registration methods of the Unity container. It contains the following topics:

  • Using Run-Time Configuration. This topic describes the fluent interface that Unity exposes, and other issues you should be aware of when configuring the container at run time using code.
  • Registering Types and Type Mappings. This topic explains how to register mappings in the container between types. In general, you will create mappings between an interface and a type that implements the interface, or between a base class and a type that inherits that base class.
  • Creating Instance Registrations. This topic explains how to register existing objects in the container that you can resolve in your application. This technique is useful if you want Unity to manage the lifetime of the objects you register.
  • Registering Injected Parameter and Property Values. This topic explains how to register the information required so that Unity will automatically populate constructor and method parameters and property values when it resolves instances of types.
  • Registering Generic Parameters and Types. This topic explains how you can register the information required for injection for generic types, including generic arrays.
  • Registering Container Extensions. This topic explains how to register information that instructs Unity to load and use container extensions that add additional functionality to the container, and how you can register configuration information for these extensions.
  • Registering Interception. This topic explains how to register behaviors, policies, handlers, and matching rules that Unity will use when creating instances of types to which you want to add interception capabilities to change the behavior of that object or type.

For information about how to configure Unity at design time, including the techniques for loading configuration from a file or other source, see Design-Time Configuration. For information about resolving types at run time, see Resolving Objects.