Architecture of an Application Block in Enterprise Library
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 IProviderBaseGlossary of Terms in Microsoft Enterprise Library
application block. A reusable software component that is designed to help developers with common enterprise development challenges. For example, the Enterprise Library includes a Data Access Application Block that developers can use to incorporate standard database functionality into their applications.
base node. The design-time counterpart of the run-time provider base class. Generally, the base node is defined in the BaseClassName Data class. The design-time project includes this class.
design - time project. The design-time project contains the files that make the application block and its providers visible and configurable in the Configuration Console and Visual Studio Configuration Editor.
default instance. The provider instance that the application block creates if the Create method has no type parameter. You define the default instance in the Create New Provider Factory and Base Wizard.
provider node. The design-time counterpart of the run-time provider implementation. The Application Block Software Factory creates a node when you complete the Create a Design-Time Provider Node wizard. Generally, the node is defined in the ProviderName Data class. The design-time project includes this class.
parent UI node. The node that contains the current node in the configuration hierarchy.
provider. A .NET object that supplies some functionality. The Enterprise Library includes many providers. For example, there is a provider that allows you to connect to a SQL database, execute commands, and retrieve results. The Application Block Software Factory creates a provider implementation when you complete the Create New Provider wizard. Generally, the ProviderName class defines the provider implementation. The run-time project includes this class. You can create either typed providers or untyped providers. Typed providers have strongly-typed their own strongly-typed configuration classes. Untyped providers use a generic name/value collection.
provider base class. The class from which provider implementations derive. The Application Block Software Factory creates a provider base class when you complete the Create New Provider Factory and Base wizard. Generally, the ProviderBaseClassName class defines the base class. The he run-time project includes this class.
provider library. A .NET Framework assembly with a corresponding Visual Studio project that contains a number of providers. These providers extend the functionality of an application block. This application block is included in a different assembly.
reference node. A node that the current node needs to correctly function. When you use the Application Block Software Factory to build a design-time project, you enter the value of a property’s reference node when you use the Create a Design-Time Provider Node wizard. Reference nodes appear as types in the dropdown list in the Configuration Console’s property pane. For example, in the Logging Application Block, if you have a trace listener that logs to a database, the reference node is the connection string for the database. If you are using a SQL database, you use the dropdown list to select System.Data.SqlClient as the type. You define a reference node when you define a provider’s properties in the Create New Provider wizard.
run-time configuration type. The class that contains the configuration information that the design time uses for the configuration tools.
typed provider. A provider that includes a ProviderName Data class. This class contains the run-time configuration information. This configuration information can be used in the design-time project so that the provider’s properties and values will appear in the configuration tools.
untyped provider. A provider that has a generic provider data class. This class uses a name/value collection that can apply to different types of providers.
Posted in: Software Programming C# and .NET| Tags: NET Enterprise Library Microsoft Enterprise Library application block base node default instance provider node provider reference node provider library