The Custom Attribute Matching Rule
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 Unity Application Block information can be found at the Unity Application Block 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.
In more detail, the Custom Attribute Matching Rule does the following:
- It reads the value of the AttributeType and the inherited parameters from the Unity 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 inherited parameter is True.
- It returns True if the attribute type matches the value of the AttributeType parameter; if the attribute type does not match the value of the AttributeType, it returns False.
Unity uses constructor injection to generate new instances of matching rules. For information about constructor injection, see the following topics:
- Streamlining Interception by Using PolicyDefinition API
- Configuration Support for Interception
- Configuring Containers at Run Time
The following constructor can be used for the CustomAttributeMatchingRule class.
The constructor parameters make the following configuration settings available for the Custom Attribute Matching Rule:
- AttributeType (Type). This is the type name of the custom attribute that is applied to members of the target object, such as "MyCustomAttribute".
- inherited (Boolean). This specifies whether the rule should also search base classes for members that carry the custom attribute.