Share via


Dependency Schematics

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

This section provides schematic views of the relationships and dependencies between the Enterprise Library application blocks and the Enterprise Library core. These schematics will help you to understand the requirements for deploying applications that use Enterprise Library and assist in ensuring you deploy the appropriate assemblies.

There are several ways that you can generate instances of Enterprise Library objects (such as Database and CacheManager); the technique you use has an effect on the dependencies between the Enterprise Library artifacts. You can use the following techniques to generate instances of Enterprise Library objects:

  • Use the factory classes in each application block and the Enterprise Library core
  • Use the Unity Application Block to create instances of any type
  • Use Unity or a third-party dependency injection mechanism without the Enterprise Library core

For more details of how you can create object instances using all of these techniques, see Creating Application Block Objects and the section that describes The Unity Application Block.

Using the Enterprise Library Factory Classes

This version of Enterprise Library supports the same mechanism for generating instances of Enterprise Library objects as earlier versions. Each of the application blocks, and the Enterprise Library core, contain factory classes that developers can use to create instances of objects. For example, they can create an instance of the CacheManager class for a specified cache manager defined in configuration using the following code.

CacheManager diskCache = CacheFactory.GetCacheManager("name");
'Usage
Dim diskCache As CacheManager = CacheFactory.GetCacheManager("name")

This technique uses common code in the Enterprise Library core, which makes calls directly to the ObjectBuilder utility, as shown in Figure 1. Therefore, all the application blocks have a dependency on the Enterprise Library core and on ObjectBuilder. Figure 1 also shows how the use of each application block as a provider for other application blocks (for example, when using the Cryptography Application Block to encrypt data cached using the Caching Application Block) creates optional dependencies between the application blocks.

Ff647614.2e8fd2b5-34d2-4fe6-a175-e3036a0c1c17(en-us,PandP.10).png

Figure 1
Inter-block and core dependencies for basic Enterprise Library object generation

When using this technique to generate objects, you must deploy the following:

  • The core library assembly Microsoft.Practices.EnterpriseLibrary.Common.dll
  • The ObjectBuilder assembly Microsoft.Practices.ObjectBuilder2.dll
  • The assemblies for all application blocks used in the application, including the assemblies that contain providers used with each application block.

Using the Unity Application Block

The Unity Application Block allows developers to generate instances of all kinds of objects using the Dependency Injection pattern. The application block will automatically inject instances of dependent objects into the returned object as required. You can use this approach to generate instances of any of the Enterprise Library objects and instances of your own custom business objects. Figure 2 shows how using the Unity Application Block changes the dependencies between the application blocks and the Enterprise Library core.

Ff647614.1721656c-0938-48dc-85fa-37a195468598(en-us,PandP.10).png

Figure 2

Inter-block and core dependencieswhen using the Unity Application Block to generateEnterprise Library objects

In this case, all the application blocks except for the Unity Application Block will still depend on the configuration system within the Enterprise Library core. However, although the Unity Application Block can use configuration information stored in the App.config or Web.config file of the application, it does not automatically create and configure the Unity containers. Instead, developers must create the containers and load the configuration information using code within the application. For details of how to do this, see Creating Objects Using the Unity Application Block.

After they create and configure the container, developers can generate object instances (in this example, a CacheManager) using the syntax in the following code.

CacheManager diskCache = myContainer.Resolve<CacheManager>("name");
'Usage
Dim diskCache As CacheManager = myContainer.Resolve(Of CacheManager)("name")

When using this technique to generate objects, developers must deploy the following:

  • The core library assembly Microsoft.Practices.EnterpriseLibrary.Common.dll (for the application blocks other than the Unity Application Block)
  • The Unity Application Block assembly Microsoft.Practices.Unity.dll
  • The Object Builder assembly Microsoft.Practices.ObjectBuilder2.dll
  • The assemblies for all other application blocks used in the application, including the assemblies that contain providers used with each application block

Use Unity or a Third-Party Dependency Injection Mechanism

The Unity Application Block is designed for use both with Enterprise Library as a general dependency injection container mechanism and as a stand-alone dependency injection container mechanism. In addition, if required, developers can replace Unity with any other third-party dependency injection framework. Figure 3 shows the relationships and dependencies between the artifacts in this case.

Ff647614.0d254d4e-73c8-4f3a-baa4-6f9f9199609a(en-us,PandP.10).png

Figure 3

Inter-block and core dependencieswhen using Unity or a third-party dependency injection mechanism to generateEnterprise Library objects

This approach requires that the dependency injection framework that is used supports configuration that specifies the objects, settings, and relationships necessary for the applications blocks. The Unity Application Block contains sample configurations for the Enterprise Library application blocks.

When using this technique to generate objects, developers must deploy the following:

  • The assemblies for all application blocks used in the application, including the assemblies that contain providers used with each application block.
  • The Enterprise Library Common assembly, which contains the Enterprise Library Core shared features used by all the application blocks.
  • If they use the Unity Application Block as the dependency injection mechanism, developers must deploy the assembly Microsoft.Practices.Unity.dll and the ObjectBuilder assembly Microsoft.Practices.ObjectBuilder2.dll.
  • If they use an alternative dependency injection mechanism, developers must deploy the corresponding assemblies and artifacts for this mechanism.