Share via


Source Schema for Enterprise Library Core

The Enterprise Library Core provides services, such as instrumentation and configuration, and all Enterprise Library application blocks except for Unity are dependent on the core. The core library functionality is contained in the assembly Microsoft.Practices.EnterpriseLibrary.Common.dll.

There are two configuration sections associated with the Enterprise Library Core. They are the instrumentationConfiguration section and the enterpriseLibrary.ConfigurationSource section. These sections define which types of instrumentation are enabled in the application (if any), and which configuration source should be used to access configuration information within the application. The following XML code shows the configuration section declarations that define the locations of these configuration sections. These declarations should be defined within the <configSections> section of the application configuration file.

<configSections>

  <section name="instrumentationConfiguration"
           type="Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.Configuration.InstrumentationConfigurationSection,
                 Microsoft.Practices.EnterpriseLibrary.Common" />

  <section name="enterpriseLibrary.ConfigurationSource"
            type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection,
                 Microsoft.Practices.EnterpriseLibrary.Common" />

</configSections>

If there is no enterpriseLibrary.ConfigurationSource section in the configuration file, an instance of the SystemConfigurationSource class becomes the configuration source for the application. This means that when the application creates Enterprise Library objects, it retrieves configuration information from the application configuration file.

enterpriseLibrary.ConfigurationSource Element

The enterpriseLibrary.ConfigurationSource element specifies the configuration source that the application should use. This element is not required. If it is omitted, the application uses an instance of the SystemConfigurationSource class.

The following sections describe attributes and child elements of the enterpriseLibrary.ConfigurationSource element.

Attributes

The following table lists the attributes for the enterpriseLibrary.ConfigurationSource element.

Attribute

Description

selectedSource

The configuration source to use for this application. It must be a name listed in the <sources> section. This attribute is required.

parentSource

The configuration source to use for this application to inherit from. It must be a name listed in the <sources> section. This attribute is optional.

<enterpriseLibrary.ConfigurationSource selectedSource="externalChildSource" parentSource="externalParentSource">
  <sources>
    <add name="externalParentSource"
         type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, 
               Microsoft.Practices.EnterpriseLibrary.Common"
         filePath="parentconfiguration.config" /> 
    <add name="externalChildSource" 
         type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, 
               Microsoft.Practices.EnterpriseLibrary.Common" 
         filePath="currentconfiguration.config" /> 
  </sources>
</enterpriseLibrary.ConfigurationSource>

sources Element

The sources element is a child of the enterpriseLibrary.ConfigurationSource element. It lists the configuration sources that the application can use. This element is required.

add Element

The add element is a child of the sources element. It specifies the name of a configuration source. This element is optional. There can be multiple add elements.

The following table lists the attributes for the add element.

Attribute

Description

name

The name of the configuration source. The name must be unique within the section. This attribute is required.

type

The type name of a class that implements the IConfigurationSource interface.

filePath

The path that points to the configuration file. This attribute is required if the configuration source is a file.

If you are using the example SQL Server configuration source that is provided as a separately downloadable QuickStart example, you can use the following attributes to specify the connection and stored procedures it uses.

Attribute

Description

connectionString

The SQL Server connection string for the SQL Server database that contains the configuration information. This attribute is required if the configuration source is a SQL Server database.

getStoredProcedure

The name of a stored procedure in the database that contains the configuration information. This is the stored procedure to call when the application gets a configuration section. This attribute is required if the application uses a stored procedure with a SQL Server database to get a configuration section.

setStoredProcedure

The name of a stored procedure in the database that contains the configuration information. This is the stored procedure to call when the application sets a configuration section. This attribute is required if the application uses a stored procedure with a SQL Server database to set a configuration section.

refreshStoredProcedure

The name of a stored procedure in the database that contains the configuration information. This is the stored procedure to call when the application refreshes a configuration section. This attribute is required if the application uses a stored procedure with a SQL Server database to refresh a configuration section.

removeStoredProcedure

The name of a stored procedure in the database that contains the configuration information. This is the stored procedure to call when the application removes a configuration section. This attribute is required if the application uses a stored procedure with a SQL Server database to remove a configuration section.

instrumentationConfiguration Child Element

The instrumentationConfiguration element enables and disables the different types of instrumentation. This element is optional. If this element is not included in the configuration source, all instrumentation is disabled.

The following table lists the attributes for the instrumentationConfiguration element.

Attribute

Description

performanceCountersEnabled

Specifies whether the application blocks used by the application will write to the performance counters. Possible values are true and false. The default value is false. This attribute is optional.

eventLoggingEnabled

Specifies whether the application blocks used by the application will write to the event log. Possible values are true and false. The default value is false. This attribute is optional.