Source Schema for the Policy Injection Application Block

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.

This topic lists the elements and attributes used to configure the Policy Injection Application Block. The configuration file has the following section-handler declaration.

<configSections>
  <section name="policyInjection"
           type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.PolicyInjectionSettings,
                 Microsoft.Practices.EnterpriseLibrary.PolicyInjection,
                 Version=4.1.0.0, Culture=neutral,
                 PublicKeyToken=31bf3856ad364e35" />
</configSections> 

The section Element

The section-handler declaration contains the name of the configuration settings section and the name of the section-handler classes that process configuration data in that section.

Attributes of the section Element

The following table describes the attributes of the <section> element.

Attribute

Description

name

The name of the element containing the configuration settings (the section for the application block) located later in the configuration file. The name is policyInjection.

type

The name of the section-handler class for the configuration settings section. The class name is PolicyInjectionSettings. The namespace for this class, and all other configuration classes used by the application block, is Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.

The policyInjection Element

The <policyInjection> element is the root of the configuration for the Policy Injection Application Block. It encloses a single <policies> element that contains the individual policies.

The following elements define these policies:

  • The policies Element
  • The matchingRules Element
  • The matches Element
  • The parameters Element
  • The parameter Element
  • The handlers Element

The next sections describe each of these elements.

The policies Element

The <policies> element encloses the list of policies in the configuration and contains a series of <add> elements that specify the individual policies.

Attributes of the policies Element

The following table describes the attributes of the <policies> element.

Attribute

Description

name

A name that can be used to identify the element.

Child Elements of the policies Element

Each <add> element within the <policies> element specifies the complete configuration for a single policy. It does this through two child elements named <matchingRules> and <handlers>.

Attributes of the add Element for Policies

The following table describes the attributes of each <add> element that can occur within the <policies> element to describe a policy.

Attribute

Description

name

The name by which code in the application block and the configuration tools will refer to this policy.

The matchingRules Element

The <matchingRules> element encloses the list of matching rules for a policy and contains a series of <add> elements that specify the individual matching rules.

Child Elements of the matchingRules Element

Each <add> element within the <matchingRules> element specifies details of a single matching rule. The combination of matching rules within a <matchingRules> element must all evaluate to True for a policy to apply.

Attributes of the add Element for Matching Rules

The following table describes the attributes of each <add> element that can occur within the <matchingRules> element to describe a matching rule.

Attribute

Description

name

The name by which code in the application block and the configuration tools will refer to this matching rule.

type

The name of the matching rule class, the name of the containing assembly, the version, the culture information, and the public key token.

match

Used only by the AssemblyMatchingRule, MethodSignatureMatchingRule, ParameterTypeMatchingRule, ReturnTypeMatchingRule, and TagAttributeMatchingRule. A string containing the value that the matching rule will compare against the target assembly name, method name, tag name, parameter type, or return type. May consist of or contain the *, ? and [ ] wildcard characters except when matching an assembly name or a root namespace name.

ignoreCase

Used only by the MethodSignatureMatchingRule, ReturnTypeMatchingRule, and TagAttributeMatchingRule. Specifies whether the match against the method name, tag name, parameter type, or target return type is case sensitive.

searchInheritanceChain

(Optional) Used only by the CustomAttributeMatchingRule. Specifies whether the rule will search for custom matching attributes in inherited classes or only in the currently invoked concrete class. The default setting is false.

attributeType

Used only by the CustomAttributeMatchingRule. Specifies the type name of the attribute to search for.

Child Elements of the add Element for Matching Rules

Some of the matching rules contain a list of values (referred to as "match values") that the application block will compare against the target class when adding pipeline handlers. In these cases, the <add> element for a matching rule can contain a <matches> element, which itself contains a series of <add> elements. The application block applies all the <add> element values by combining them using the OR operator so the application block will apply the policy if any one of them matches the target. This applies to the following matching rule types:

  • MemberNameMatchingRule
  • NamespaceMatchingRule
  • ParameterTypeMatchingRule
  • PropertyMatchingRule
  • TypeMatchingRule

One exception is the MemberSignatureMatchingRule, which contains a <parameters> child element that contains one or more <parameter> elements defining the matching parameter types for this rule. In this case, the series of <parameter> types, and their order within the <parameters> element, must exactly match the target member signature.

The matches Element

The <matches> element encloses the list of match values for the matching rule of a policy and contains a series of <add> elements that specify the individual match values.

The add Element for Matches

Each <add> element within a <matches> element defines one value the application block will compare to the target class to determine whether this rule matches. The types of value differ depending on the matching rule. The matching rule combines the values of all the <add> elements using an OR operation so the matching rule will return true if any one of the values matches the target.

Attributes of the add Element for Matches

The following table describes the attributes of the <add> element for matches.

Attribute

Description

match

A string containing the value that the matching rule will compare against the target member name, namespace name, property name, or type. May consist of or contain the *, ?, and [ ] wildcard characters for some rules.

matchOption

Used only by the PropertyMatchingRule. A string containing a value from the PropertyMatchingOption enumeration that the matching rule will use to check whether the target property has the appropriate combination of accessors (Get | Set | GetOrSet).

parameterKind

Used only by the ParameterMatchingRule. A string containing a value from the ParameterKind enumeration that the matching rule will use to check the usage of matching target member parameters (Input | Output | InputOrOutput | ReturnValue).

ignoreCase

Specifies whether the match against the target member name, namespace name, property name, or type is case sensitive.

The parameters Element

The <parameters> element encloses the list of parameter types for the matching rule of a policy and contains a series of <parameter> elements that specify the individual parameter types and their order.

The parameter Element

The <parameter> element defines the type for one parameter in the target member signature. The matching rule checks each type in the order it occurs in the configuration with the types of each parameter of the target member. The matching rule will return True only if all of the types match the target member signature.

Attributes of the parameter Element

The following table describes the attributes of the each <parameter> child element that can occur within the <parameters> element of a MemberSignatureMatchingRule.

Attribute

Description

typeName

The full namespace and class name or just the class name of this parameter type for the method selected by this MemberSignatureMatchingRule—for example, "System.String".

The following extract shows an example of the configuration for a MemberSignatureMatchingRule.

<matchingRules>
  ...
  <add name="MyMemberSignatureRule1"
       type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.MemberSignatureMatchingRule,
             Microsoft.Practices.EnterpriseLibrary.PolicyInjection, 
             Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       match="MyMethodName" ignoreCase="true">
    <parameters>
      <parameter typeName="System.Int32" />
      <parameter typeName="System.String" />
    </parameters>
  </add>
  ...
</matchingRules> 

The handlers Element

The <handlers> element encloses the list of handlers for a policy and contains a series of <add> elements that specify the individual handlers.

Attributes of the handlers Element

The following table describes the attributes of the <handlers> element.

Attribute

Description

name

The name by which code in the application block and the configuration tools can refer to this handler.

Child Elements of the handlers Element

Each <add> element within the <handlers> element specifies details of a single handler. The Policy Injection Application Block adds all the handlers within a <handlers> element to the policy pipeline in the order that they appear within the configuration or the order you specify using the Order property of each one.

Attributes of the add Element for Handlers

The following table describes the attributes of each <add> element that can occur within the <handlers> element to describe a handler.

Attribute

Description

name

The name by which code in the application block and the configuration tools will refer to this handler.

type

The name of the handler class, the name of the containing assembly, the version, the culture information, and the public key token.

order

A numeric integer value that specifies the order of each handler within the handlers pipeline. The default is zero, which means that there is no explicit order specified for that handler in relation to other handlers in the same handler chain. To specify an explicit order, set the value for each handler in a policy starting from 1. If you specify the same value for two handlers in the same policy, the application block will add them to the policy handler chain in the order that it creates them.

{various}

The handler-specific attributes that specify the properties for this handler. For a full list of the attributes and valid values for each type of handler, see Configuring and Using Pipeline Handlers.