.jpg)
型別、方法和欄位都可以依據自訂屬性進行選擇性排除,自訂屬性規則根據附註項目 (型別、方法或欄位) 的自訂屬性名稱比對結果來選取項目,選取型別、方法或欄位的規則中,可能有一或多個巢狀結構的自訂屬性規則。
型別、方法或欄位規則可能有多個關聯的自訂屬性規則,在此範例中,如果有至少一個自訂屬性規則選擇該項目,則該項目就會被選取。
下列範例選取所有 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. All rights reserved.