The Method Signature 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 Unity Application Block information can be found at the Unity Application Block site. |
The Method Signature Matching Rule allows developers, operators, and administrators to select target classes based on the name and signature (the list of parameter types) of its members. This rule allows the use of wildcard characters for the member names.
Behavior of the Method Signature Matching Rule
In more detail, the Method Signature Matching Rule does the following:
- It reads the methodName and ignoreCase properties, and the collection of parameter match definitions (each containing the TypeName property), from the Unity Application Block configuration.
- It compares the string value of the methodName property with the name of the method, taking into account any wildcard characters in the match string.
- It performs the comparison on a non-case-sensitive basis if the ignoreCase property is True or on a case-sensitive basis if the ignoreCase property is False.
- If the method name matches, it compares each parameter definition in the configuration to the type name of each parameter of the target member methods in the order they appear in the configuration.
- It returns True if the method name and all the configured parameter type names match those of a target member; if the method name and all the configured parameter type names do not match those of a target member, it returns False.
Configuration Using Constructor Injection forMethod Signature Matching Rule
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 overloads can be used for the MethodSignatureMatchingRule class.
public MethodSignatureMatchingRule(
IEnumerable<string> parameterTypeNames
)
public MethodSignatureMatchingRule(
IEnumerable<string> parameterTypeNames,
bool ignoreCase
)
public MethodSignatureMatchingRule(
string methodName,
IEnumerable<string> parameterTypeNames
)
public MethodSignatureMatchingRule(
string methodName,
IEnumerable<string> parameterTypeNames,
bool ignoreCase
)
The constructor parameters make the following configuration settings available for the Method Signature Matching Rule:
- methodName (String). This is the name of the target member method. It can consist of or include the * or ? wildcard characters to select multiple methods. You can also use square brackets [ ] to specify a range of characters.
- ignoreCase (Boolean). This specifies whether the method name match should be carried out on a case-sensitive basis.
- parameterTypeNames. This is a collection of parameter type names to match, each consisting of a single parameter:
- TypeName (String). This is the type name of the target member parameter.