Creating Application Block Objects
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. |
Your application will usually need to create instances of application block objects, such as Database and CacheManager, and Enterprise Library supports a range of techniques for creating instances of objects for use in your applications.
You can use the factory classes within Enterprise Library to create instances of these objects. Each of the application blocks and the Enterprise Library Core contain specific factory classes for this purpose. The static factory methods automatically take into account the current Enterprise Library configuration information. The provider factory methods allow you to create the appropriate configuration source manually and use this to create the provider.
Alternatively, you can create instances of application block objects directly when you do not need them to take account of configuration information. For example, you can create a SqlDatabase instance simply by specifying the connection details in the call to the class constructor.
In addition, Enterprise Library version 4.1 includes the Unity Application Blockāa lightweight, extensible dependency injection container with support for constructor, property, and method call injection.
The following sections provide information about the different approaches for creating instances of application block objects described earlier:
- Creating Objects Using the Static Factory Methods
- Creating Objects Using the Provider Factory Methods
- Creating Objects Using the Unity Application Block
- Constructing Application Block Objects Directly
Note
You can use the Unity Application Block to create instances of your own custom business objects and services in addition to using it to create instances of application block objects. For more details, see The Unity Application Block.