Share via


The Custom Attribute Matching Rule

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 Custom Attribute Matching Rule allows developers, operators, and administrators to select target classes based on a custom attribute type that is applied to class members.

Behavior of the Custom Attribute Matching Rule

In more detail, the Custom Attribute Matching Rule does the following:

  • It reads the value of the AttributeType and the SearchInheritanceChain properties from the Policy Injection Application Block configuration.
  • It compares the AttributeType value to the type of any attributes that are applied to members of the target object.
  • It searches for matching attribute types in all base classes that the target class inherits from if the SearchInheritanceChain property is True.
  • It returns True if the attribute type matches the value of the AttributeType property; if the attribute type does not match the value of the AttributeType, it returns False.

Configuration Settings of the Custom Attribute Matching Rule

The configuration settings available for the Custom Attribute Matching Rule are the following:

  • AttributeType (Type). This is the type name of the custom attribute that is applied to members of the target object, such as "MyCustomAttribute".
  • SearchInheritanceChain (Boolean). This specifies whether the rule should also search base classes for members that carry the custom attribute.

The next procedure describes how to configure the Custom Attribute Matching Rule using the Configuration Console or the Visual Studio 2005 Configuration Editor.

To configure the Custom Attribute Matching Rule

  1. Right-click the Matching Rules node in the Enterprise Library Configuration Console or Visual Studio Configuration Editor, point to New, and then click Custom Attribute Matching Rule.
  2. In the right pane of the Enterprise Library Configuration Console, or in the Visual Studio Properties window, select the Name property, and then change the default name to the name you want to use for the new matching rule.
  3. Select the AttributeType property and enter the full type name of the attribute applied to classes or members you want the rule to select. For example, if the attribute you use is [MyCustomAttribute], enter the value MyCustomAttribute.
  4. Select the SearchInheritanceChain property, and then in the drop-down menu, click either True (to select this class or member if a base or inherited class or class member has this attribute) or False )to ignore base and inherited classes).
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.