如何确定某个类是否使用特定属性进行修饰

Mat*_*uwe 5 vb.net attributes

我正在尝试确定界面是否使用特定属性进行修饰.例如,我有以下界面:

<MyCustomAttribute()> _
Public Interface IMyInterface
    Function Function1
    Sub DeleteWorkflowInstanceMap(ByVal instanceId As Guid)
    Sub InsertWorkflowInstanceMap(ByVal instanceId As Guid, ByVal aliasName As String)
End Interface
Run Code Online (Sandbox Code Playgroud)

如何确定IMyInterface是否使用MyCustomAttribute属性进行修饰?

Mar*_*lin 7

甚至比GetCustomAttributesShared方法更好IsDefined:

Attribute.IsDefined(GetType(IMyInterface), GetType(MyCustomAttribute))
Run Code Online (Sandbox Code Playgroud)