다음을 통해 공유


Dependency Injection with Unity

If you are using dependency injection (DI) through a DI container approach to your application development, you can use any available DI container including the container provided by Unity. Using the Unity dependency injection container provides opportunities for you to more easily decouple components, business objects, and services you use in applications, and can simplify how you organize and architect these applications.

You can create instances of objects using the DI container provided by Unity. Unity is available as a stand-alone dependency injection mechanism.

The following sections of this topic will help you to understand the overall process, and use Unity dependency injection in your applications:

  • Using BuildUp to Wire Up Objects Not Created by the Container. This topic explains how to use BuildUp to pass existing object instances through the container in order to apply dependency injection to that object. This is an alternative to resolving the object using any of the other techniques available with Unity.
  • Using Injection Attributes. This topic contains a series of sections that describe how you can use attributes applied to members of target classes to instruct Unity to inject dependent objects for constructor and method parameters, and as the values of properties.
  • Circular References with Dependency Injection. This topic describes how you should be aware of the possibility of circular references arising when using dependency injection techniques.