2015-07-20 135 views
0

这里是我的情况,我使用这个属性MyAttrAttribute遍及我的代码库,我现在想给它的属性,我使用的任何地方[MyAttr],它也适用于第三方属性[TheirAttr]扩展属性

当然,我可以在我的代码中找到替换来扩展属性,但是有没有办法修改MyAttrAttribute以应用第三方属性?

回答

0

你可以从TheirAttrAttribute获得MyAttrAttribute,然后Attribute.GetCustomAttribute方法应与这两种类型:

public static Attribute GetCustomAttribute(
    Assembly element, 
    Type attributeType 
) 

....
属性类型
       类型:System.Type
       要搜索的自定义属性的类型或基本类型。