The Unity Application Block (Unity) is a lightweight extensible dependency injection container with support for constructor, property, and method call injection.
Unity 是一个轻量级可扩展依赖注入容器,支持构造方法、属性和方法。
Unity addresses the issues faced by developers engaged in component-based software engineering. Modern business applications consist of custom business objects and components that perform specific or generic tasks within the application, in addition to components that individually address cross cutting concerns such as logging, authentication, authorization, caching, and exception handling.
Unity 解决了开发人员在做基于组件的软件工程的时候遇到的问题。现代的业务应用程序由客户端业务对象,执行特定或一类任务的组件,加上一些独立处理关联的概念,比如日志、登录认证、授权、缓存和错误处理。
The key to successfully building such applications is to achieve a decoupled or very loosely coupled design. Loosely coupled applications are more flexible and easier to maintain. They are also easier to test during development. You can mock up shims (lightweight mock implementations) of objects that have strong concrete dependencies; such as database connections, network connections, ERP connections, and rich user interface components.
开发这种应用程序的关键是解耦或者松耦合的设计。松耦合的应用程序更加灵活和易于维护,同时开发当中更容易测试。你可以模拟(轻量的模拟实现)强依赖关系对象的部分,比如数据库连接、网络连接、ERP 连接和富用户接口组件。
Dependency injection is a prime technique for building loosely coupled applications. It provides ways to handle the dependencies between objects. For example, an object that processes customer information may depend on other objects that access the data store, validate the information, and check that the user is authorized to perform updates. Dependency injection techniques can ensure that the customer class correctly instantiates and populates all of these objects, especially where the dependencies may be abstract.
依赖注入是创建松耦合应用程序的主要技术。它提供了处理对象关系的方法。例如,一个对象处理客户的信息可能依靠其它数据访问、信息有效性验证、判断用户是否有权限执行更新的对象。依赖注入技术可以保证用户对象被正确的实例化,并且在复杂关系的时候可以生成所需要的对象。
IoC(Inverse of Control)控制反转。在 Java 开发中, IoC 意味着将你设计好的类交给系统去控制,而不是在你的类内部控制。这称为控制反转。