Share via


The Property 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 Property Matching Rule allows developers, operators, and administrators to select individual properties of the target classes based on their name, including using wildcard characters, and the combination of accessors they include.

Behavior of the Property Matching Rule

In more detail, the Property Matching Rule does the following:

  • It reads the collection of match values, each containing the propertyName, option, and ignoreCase parameters, from the Unity Application Block configuration.
  • It compares each propertyName value to the name of the target object property, taking into account any wildcard characters in the match string.
  • It performs the name 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 compares target object properties with the value specified for the option parameter and selects only parameters that have the appropriate combination of Get and Set accessors.
  • It returns True if the name and the combination of Get and Set accessors of the target object matches the values in the configuration; if the name and the combination of Get and Set accessors of the target object do not match the values in the configuration, it returns False.

Configuration Using Constructor Injection for Property 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 PropertyMatchingRule class.

public PropertyMatchingRule(
IEnumerable<PropertyMatchingInfo> matches
)
public PropertyMatchingRule(
string propertyName
)
public PropertyMatchingRule(
string propertyName,
PropertyMatchingOption option
)
public PropertyMatchingRule(
string propertyName,
PropertyMatchingOption option,
bool ignoreCase
)

The configuration settings available for the Property Matching Rule are a collection of parameter matches, each consisting of three parameters:

  • matches (PropertyMatchingInfo). This is a collection of PropertyMatchingInfo objects that contain the property name pattern and other property characteristics.
  • propertyName (String). This is the name of the target property. It can include or consist of the * or ? wildcard characters to select multiple parameters. You can also use square brackets [ ] to specify a range of characters. The following are examples:
    • Get*
    • *Orders
    • *TransactedOrder???
    • BusinessRules[order]Process.*
    • *
  • option (PropertyMatchingOption). This is a value from the PropertyMatchingOption enumeration that indicates if the rule should match on the Get, Set, or both the accessors for a selected parameter. Valid values are Get, Set, and GetOrSet.
  • ignoreCase (Boolean). This specifies whether the match should be carried out on a case-sensitive basis.