Rule

Parent Previous Next

Rule


The Rule node is used to specify a single rule for implicitly associating objects of a specific name and/or type with a specific templateKey. If an explicit templateKey is present within the Structure for an object that normally would match the rule, the explicit templateKey will be used regardless of whether or not a rule matches the object type.


Syntax

This rule will implicitly map all objects to the template mapped to the key "GlobalDefault":


<Rule templateKey="GlobalDefault" />



This rule will implicitly map all objects with an object type that matches the regular expression string "Smo\.Credential$" to the template mapped to the key "SqlCredential":


<Rule templateKey="SqlCredential" typeMatch="Smo\.Credential$" />



This rule will implicitly map all objects with an object name that matches the regular expression string "Credentials$" to the template mapped to the key "SqlCredentialsCollection":


<Rule templateKey="SqlCredentialsCollection" nameMatch="Credentials$" />



This rule will implicitly map all objects with an object name that matches the regular expression string "Credentials$" and an object type that matches the regular expression string "Smo\.CredentialsCollection$" to the template mapped to the key "SqlCredentialsCollection":


<Rule templateKey="SqlCredentialsCollection" nameMatch="Credentials$" typeMatch="Smo\.CredentialsCollection$" />




Required Attributes

templateKey - Used to specify the templateKey that the following implicit rule references. If no nameMatch or typeMatch attributes are included within the rule, this rule is the default rule and will only be applied if there are no other matches found.


Optional Attributes

nameMatch - A regular expression string that is used by the Structure Map to match all objects that do not contain explicit matches based on the object's name to a templateKey. If both nameMatch and typeMatch are included, then both nameMatch and typeMatch must match for the rule to be applied.


typeMatch - A  regular expression string that is used by the Structure Map to match all objects that do not contain explicit matches based on the object's type to a templateKey. If both nameMatch and typeMatch are included, then both nameMatch and typeMatch must match for the rule to be applied.