The Namespace 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 Namespace Matching Rule allows developers, operators, and administrators to select target classes based on their namespace, using wildcard characters for the child namespace names but not for the root namespace name.

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

  • It reads the collection of match values, each containing the namespaceName and ignoreCase parameters, from the Unity Application Block configuration.
  • It compares each match string to the namespace of the target object, taking into account any wildcard characters for child namespaces. Note that the match string must specify the full root namespace name followed by a period (.).
  • 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 property is False.
  • It returns True if the namespace of the target object matches the value of any of the namespaceName values; if the namespace of the target object does not match the value of any of the namespaceName values, it returns False.

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 NamespaceMatchingRule class.

public NamespaceMatchingRule(
IEnumerable<MatchingInfo> matches
public NamespaceMatchingRule(
string namespaceName
public NamespaceMatchingRule(
string namespaceName,
bool ignoreCase

The configuration settings available for the Namespace Matching Rule are a collection of namespace name matches, each consisting of two parameters:

  • matches (MatchingInfo). A collection of MatchingInfo objects, which contain the pattern and the case sensitivity.
  • namespaceName (String). This is the namespace of the target object, such as "MyObjects.BusinessRules" or "System.Collections". It can include the * or ? wildcard characters to select multiple child namespaces. The following are examples:
    • System.Collections.*
    • MyObjects.Order*
    • MyObjects.Order??
    • MyObjects.*
  • ignoreCase (Boolean). This specifies whether the match should be carried out on a case-sensitive basis.