Defining and Configuring Matching Rules

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.

The Policy Injection Application Block uses a set of matching rules within each policy to select the class, and the members of that class, to which the handler pipeline for that policy will apply. A matching rule is essentially a predicate that the application block checks each time it intercepts object creation or wrapping. If all the specified matching rules evaluate to True for any particular invocation, the application block will create and add the handler pipeline for that policy.

Table 1 shows the full list of matching rule types available in the Policy Injection Application Block.

Table 1: Matching Rule Predicates for Policy Injection Application Block Policies

Matching rule type

Predicate description

Matching rule parameters

AssemblyMatchingRule

Class is in the specified assembly.

Assembly name (String),

exact match only on the assembly name; the name and version; the name, version and culture; or the full assembly name.

CustomAttributeMatchingRule

Class or member has an arbitrary attribute applied.

Custom attribute type (Type),

whether to search the entire inheritance chain (Boolean),

exact match only.

MemberNameMatchingRule

Class member has one of the specified names.

Target method/property names (String collection),

ignore case (Boolean),

exact or wildcard character match.

MethodSignatureMatchingRule

Class method has the specified signature.

Target method name (String),

type names of target method parameters (String collection), ignore case (Boolean),

uses the same type matching rules as the TypeMatchingRule.

NamespaceMatchingRule

Class is in one of the specified namespaces.

Namespace names (String collection),

ignore case (Boolean),

exact match on root namespace, and exact or wildcard character match on child namespaces.

ParameterTypeMatchingRule

Class member has a parameter or return value that matches one of the specified types.

Target type names (String collection),

parameter type (Input | Output | InputOrOutput | ReturnValue),

ignore case (Boolean),

uses the same type matching rules as the TypeMatchingRule.

PropertyMatchingRule

Class property has one of the specified names and contains the specified combination of accessors.

Property names (String collection),

accessor options (Get | Set | GetOrSet),

ignore case (Boolean),

exact or wildcard character match.

ReturnTypeMatchingRule

Class member accepts or returns an object of the specified type.

Type name of target method return type (String),

ignore case (Boolean),

exact or wildcard character match.

TagAttributeMatchingRule

Class member carries a Tag attribute with the specified string.

Tag attribute name (String),

ignore case (Boolean),

exact match only.

TypeMatchingRule

Class is of one of the specified types.

Target type names (String collection),

ignore case (Boolean),

exact match only on the namespace-qualified type name, or just the type name.

Developers can also create custom matching rules if required. For more details, see Extending and Modifying 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.