The main improvements to Enterprise Library 4.0 and 4.1 are the addition of brand new and easy-to-use object creation methods, including other dependent objects. This function is exposed in the Unity module of the Enterprise Library through dependency injection, which uses the following common design patterns.
- Dependency injection dependency Injection
- Inversion of control (IOC) inversion control
- Service Locator Service Positioning
- Service Container Service container
- Factory Mode
- Builder creator Mode
1. Object creation and dependency injection in the enterprise database
At the beginning, the application modules, core modules, and Configuration Systems in the Enterprise Library were all used by users to create objects, including Singleton instances, using the objectbuilder System of the Microsoft patterns & Practices Team.
Objectbuiler implements many of the modes listed above, but for mostProgramIt is not an easy-to-use tool. Using it requires developers to have significant development knowledge and time to recognize its benefits. Therefore, 4.1 of Enterprise libraries have launched a lightweight Method Based on objectbuilder, providing implementation of all the modes mentioned above.
The new interface exposed by dependency injection containers is relatively simple. It also provides extensions to facilitate developers to change their behavior as needed, in addition, developers can use it as an independent container or a dependency injection framework in their own systems. It allows developers to use modern methods, such as constructors, attributes, and injection methods, dependency injection of related objects, ing of types and interfaces in containers, and some simple configurations. In addition, developers can directly interact with containers using APIs exposed by the dependency injection container, which is used by developers as a separate dependency injection framework, or it is helpful to use a third-party dependency injection framework.
Ii. Unity Module
The dependency injection method in the Enterprise Library is exposed through a completely new module called Unity. This module implements the container mode and is used with objectbuilder, including the Assembly object creation function to be supported, instance creation of dependent objects and services, attribute input and method call during object creation.
You can use the dependency injection container in multiple ways. You can use the unity module in the following ways:
- Use the standard methods provided by each module and core module to create the objects required by the Enterprise Library.
- Obtain the reference of a singleton instance.
- Use dependency injection for existing objects.
- To create custom objects, you also need to create objects related to them.
- Ing interfaces and implementation classes
- Container extension can be used to expand functions or change behavior.
- Use third-party dependency injection frameworks, such as castle, Windsor, and spring, to create any types of objects in the Unity container.
Not complete .....................