Partager via


The Return Type 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 Return Type Matching Rule allows developers, operators, and administrators to select target classes based on the type name of the return value, using wildcard characters for the type name.

Behavior of the Return Type Matching Rule

In more detail, the Return Type Matching Rule does the following:

  • It reads the value of the returnTypeName and the ignoreCase parameters from the Unity Application Block configuration.
  • It compares the returnTypeName value to the full namespace and class name of the type returned by members of the target object.
  • It performs the comparison on a non-case—sensitive basis if the ignoreCase parameter is True or on a case-sensitive basis if the ignoreCase parameter is False.
  • It returns True if the type name matches the value of the match string; if the type name does not match the value of the match string, it returns False.

Configuration Using Constructor Injection for Return Type Matching Rule

Unity uses constructor injection to generate new instances of matching rules. For information about constructor injection, see the following topics:

The following constructor overloads can be used for the ReturnTypeMatchingRule class.

public ReturnTypeMatchingRule(
string returnTypeName
)
public ReturnTypeMatchingRule(
Type returnType
)
public ReturnTypeMatchingRule(
string returnTypeName,
bool ignoreCase
)

The constructor parameters make the following configuration settings available for the Return Type Matching Rule:

  • returnTypeName (String). This is the full namespace-qualified type name of the target object return type, or just the type name. The following are examples:
    • System.Int32
    • String
    • Int32
  • returnType (Type). Type to look for.
  • ignoreCase (Boolean). This specifies whether the match should be carried out on a case-sensitive basis.