有什麼方法可以獲取我在方法中接收的特定對象的自定義屬性?獲取特定成員的CustomAttributes
我不希望也無法遍歷Type.GetMembers()並搜索我的成員。我有這個對象,它也是一個成員,具有這個屬性。
如何獲取屬性?
class Custom
{
[Availability]
private object MyObject = "Hello";
private void Do(object o)
{
//does object 'o' has any custom attributes of type 'Availability'?
}
//somewhere I make the call: Do(MyObject)
}
我想到了這一點,但也希望有一個聰明的方式來獲得屬性,仍然。謝謝。 – 2008-10-15 13:11:36