Sdílet prostřednictvím


Enterprise Library Configuration Integration

Enterprise Library allows you to easily integrate custom providers and extensions into the library in such a way that you can configure them using the Enterprise Library configuration tools. There are two types, or levels, of configuration integration.

Basic Configuration Integration

The simplest configuration integration approach is**basic integration, where you add your provider or extension by selecting the Add Custom [provider type] menu item for the configuration section to which you want to add your provider. This opens a type selector dialog where you select the run-time provider type. Then you configure the properties of the provider by adding name/value pairs to the provider configuration. Each name/value pair identifies the name of an attribute for the custom element in the configuration file, and the value of that attribute. At run time the Enterprise Library configuration system will instantiate your custom provider and pass to the constructor a NameValueCollection instance containing all of these values.

Ff664540.f5fd88d2-16a6-49f0-9b47-1b1077ac034b(en-us,PandP.50).png

Full Configuration Integration

The second configuration integration approach is full integration, where your custom provider appears as though it were an integral part of Enterprise Library. The provider name appears on the menu when you add a provider, and the configuration tool displays the properties that you can set using appropriate UI controls. At run time the Enterprise Library configuration system will instantiate your custom provider, and pass the individual configuration property values to its constructor.

Ff664540.349b26ea-b22f-446a-ba7c-85e994a0788d(en-us,PandP.50).png

Full integration has a number of advantages over basic integration:

  • You do not need to locate the provider assembly and specify the provider type. When you use full integration, the type is specified in the provider design-time configuration.
  • You do not need to remember the names of the attributes in the configuration file, and their meaning. When you use full integration, the console can display descriptions and pop-up tooltips for the properties and allow you to edit them using the most suitable types of UI controls.
  • You can add multiple provides to a section menu, each fine-tuned to your specific requirements, and easily differentiate between them.

In most cases, you should consider full integration with the configuration tools. This approach does require additional effort on your behalf compared to basic integration, although this is considerably reduced compared to previous versions of Enterprise Library. In addition, the ease of use of your providers makes the extra effort worth expending; especially of you use the provider in a number of locations.

For more information, see Creating a Custom Provider.