The Assembly 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 Assembly Matching Rule allows developers, operators, and administrators to select target classes based on the assembly name.
In more detail, the Assembly Matching Rule does the following:
- It reads the value of the constructor parameter to configure the matching rule for injection. For the assemblyName parameter, the value can be the assembly name; the name and version; the name, version and culture; or the fully qualified assembly name and details.
- It compares the assemblyName value to the name and version; the name, version and culture; or the fully qualified assembly name and details of the target assembly excluding the .dll file name extension.
- It returns True if the assemblyName string exactly matches the assembly details; if the match string does not exactly match the assembly details, 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 overloads can be used for the AssemblyMatchingRule class.
public AssemblyMatchingRule( Assembly assembly ) public AssemblyMatchingRule( string assemblyName )
The constructor parameters make the following configuration settings available for the Assembly Matching Rule:
- assembly (Assembly). This represents an assembly object. This is the assembly to match.
- assemblyName (String). This is the assembly name to match. This can be the name and version; the name, version and culture; or the full assembly name of the assembly excluding the .dll file name extension. It cannot include wildcard characters. The following are some examples:
- "Contoso.BusinessObjects.Sales, Contoso.BusinessObjects"
- "Contoso.BusinessObjects.Sales, Contoso.BusinessObjects, Version=126.96.36.199"
- "Contoso.BusinessObjects.Sales, Contoso.BusinessObjects, Version=188.8.131.52, Culture=neutral"
- "Contoso.BusinessObjects.Sales, Contoso.BusinessObjects, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35"