按自定义属性排除

类型、方法和字段可根据自定义属性有选择地排除。自定义属性规则对用来标注项(类型、方法或字段)的自定义属性的名称进行匹配,根据匹配结果来选择项。用于选择类型、方法或字段的任何规则的内部都可以嵌套一个或多个自定义属性规则。

一个类型、方法或字段规则可能有多个与之关联的自定义属性规则。在此情况下,如果至少有一个自定义属性规则选择了某项,则该项被选中。

下面的示例选择以 MyCustomAttribute 或 MyOtherCustomAttribute 标注的所有类型:

<type name=".*" excludetype="false" regex="true>
   <customattribute name="MyCustomAttribute"/>
   <customattribute name="MyOtherCustomAttribute"/>
</type>

自定义属性规则也可使用正则表达式编写以匹配自定义属性名。下面的示例是选择以 MyCustomAttribute 或 MyOtherCustomAttribute 标注的所有类型的另一种方法:

<type name=".*" excludetype="false" regex="true>
   <customattribute name="My.*CustomAttribute" regex="true"/>
</type>

下一个示例显示如何排除以名为 MyCustomAttribute 的自定义属性标注的所有方法:

<type name=".*" excludetype="false" regex="true">
   <method name=".*" regex="true">
      <customattribute name="MyCustomAttribute"/>
   </method>
</type>

© 2002-2007 PreEmptive Solutions. 保留所有权利。