Architecture of an Application Block in Enterprise Library

10/20/2009

The client code calls into the ProviderBase Factory class with the Create ProviderBase method. The ProviderBase Factory then calls the ProviderBase InstanceFactory class. This class calls the Enterprise Library core, which examines the I ProviderBase interface for the attribute that tells it what sort of custom factory to use. It creates an instance of that class and uses it to discover the appropriate configuration object. In this case, the correct object is the Provider Data class. The core then examines the Provider Data class for the Assembler attribute that tells it which assembler to build. It builds the assembler and passes it the Provider Data class. The assembler constructs an instance of the Provider class.

Application Block Software Factory Generated Files

Application Block Software Factory produces application blocks that have a run-time component and a design-time component. The run-time component implements the application block’s functionality. The application block also provides the configuration schema, which defines the application block’s behavior. The design-time component makes it possible to display this information in the configuration tools. Either of these tools allows you to read an application block’s current configuration, to change it and to store it. Most of an application block’s functionality and configuration information is contained in classes that implement the providers.

The Run-Time Component

Table 1 lists the most relevant run-time classes created by the Application Block Software Factory that implement a provider’s functionality.

Table 1: Run-time component classes for functionality

Class name

Description

Provider

This class is an implementation of the provider base class. The Create New Provider (Typed) or Create New Provider (Untyped) recipe creates this file.

ProviderBase Factory

This is a static class that has a Create Provider method. This method allows users to create instances of the provider. The New Provider Factory and Base recipe creates this file.

ProviderBase CustomFactory

This class finds the correct configuration information for the provider that is being instantiated and returns it to the Enterprise Library core. The New Provider Factory and Base recipe creates this file.

ProviderBase InstanceFactory

This is the entry point into the Enterprise Library core. The New Provider Factory and Base recipe creates this file.

ProviderBase

The provider base class that implements the I ProviderBase interface. Provider implementations derive from this class

I ProviderBase

The interface that the provider base class implements. The New Provider Factory and Base recipe creates this file.

Table 2 lists the run-time classes that contain an application block or a provider’s configuration information.

Table 2: Run-time component classes for configuration information

Class name

Description

ApplicationBlock Settings

This class defines the application block’s configuration information. The design-time counterpart of this file is ApplicationBlock SettingsNode class. The Create Application Block recipe creates this file.

ProviderBase DataRetriever

This is a helper class that is responsible for retrieving the default instance name from the configuration.

ProviderBase Data

This class defines the base provider class’s configuration information. The design-time counterpart is the ProviderBase Node class. The New Provider Factory and Base recipe creates this file.

Provider Data

This class defines the provider’s configuration information. The design-time counterpart is the Provider Node class. The Create New Provider (Typed) or the Create New Provider (Untyped) recipe creates this file.

The Design-Time Component

The design-time component translates between the run-time configuration classes and the Configuration Console’s UI display. Table 3 lists the most relevant design-time files created by the Application Block Software Factory.

Table 3: Design-time component classes

Class name

Description

AddApplicationBlockSettingsNodeCommand

This class represents the menu command from the application that is used to add the configuration for the block (that is, “New, Data Access Application Block”)

ApplicationBlock SettingsNode

This class mirrors the properties in the ApplicationBlock SettingsNode. It represents the block’s top-level node in the configuration tool.

ApplicationBlock SettingsBuilder

This class translates the information in the UI configuration hierarchy nodes into run-time configuration classes. This is necessary in order to save the configuration information. The Create New Application Block recipe creates this file.

ApplicationBlock SettingsNodeBuilder

This class reads the configuration information by translating run-time configuration information into UI configuration hierarchy nodes. The Create New Application Block recipe creates this file.

CommandRegistrar

This class contains commands that place the nodes at the correct places in the configuration hierarchy. For example, the CreateSingleUICommand command ensures that a node only appears once. This class also associates the nodes with the correct UI commands such as Rename and Replace. The Create New Application Block recipe creates this file.

ConfigurationDesignManager

This class defines the UI commands, such as New, and the node maps for the configuration hierarchy. A node map defines the correspondence between the run-time configuration information and a UI node. It also contains the OpenCore method that reads the configuration information. The Create New Application Block recipe creates this file.

NodeMapRegistrar

This is a helper class that creates a mapping between nodes and configuration information. The Create New Application Block recipe creates this file.

ProviderBase Node

This class mirrors the properties in the ProviderBase Data class. It also defines characteristics such as the Configuration Console category for the property and whether or not the property is required. The New Provider Factory and Base recipe creates this file.

Provider Node

This class mirrors the properties in the Provider Data class. It also defines characteristics such as the Configuration Console category for the property and whether or not the property is required. The Create Design-Time Provider Node recipe creates this file.

Posted in: Software Programming C# and .NET| Tags: NET Enterprise Library Microsoft Enterprise Library application block provider ProviderBaseFactory CreateProviderBase IProviderBase

Hot Posts

Latest posts

Tags

Others

Sponsors

asp.net interview questions