如何确定一类装饰有特定属性 [英] How to determine if a class is decorated with a specific attribute
本文介绍了如何确定一类装饰有特定属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想,以确定是否接口,装饰有一个特定的属性。例如,我有以下接口:
I'm trying to determine if a interface is decorated with a specific attribute. For example, I have the following interface:
<MyCustomAttribute()> _
Public Interface IMyInterface
Function Function1
Sub DeleteWorkflowInstanceMap(ByVal instanceId As Guid)
Sub InsertWorkflowInstanceMap(ByVal instanceId As Guid, ByVal aliasName As String)
End Interface
我如何确定是否IMyInterface的装饰与MyCustomAttribute属性?
How do I determine if IMyInterface is decorated with the MyCustomAttribute attribute?
推荐答案
甚至比 GetCustomAttributes
更是共享的方法 IsDefined
:
Even better than GetCustomAttributes
is the Shared method IsDefined
:
Attribute.IsDefined(GetType(IMyInterface), GetType(MyCustomAttribute))
这篇关于如何确定一类装饰有特定属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文