Visual C++ .NET/Reflection/Attribute — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 18:31, 26 мая 2010
Get custom attribute
<source lang="csharp">
- include "stdafx.h"
using namespace System; [AttributeUsageAttribute(AttributeTargets::Assembly | AttributeTargets::Class)] public ref class OwnerAttribute : Attribute {
public: property String^ DevOwner; property String^ TestOwner; OwnerAttribute() { }
}; [ Owner(DevOwner="John") ] ref class C2 { };
int main() {
Attribute^ attribute = Attribute::GetCustomAttribute( C2::typeid,OwnerAttribute::typeid); if (attribute != nullptr) { Console::WriteLine("{0}", attribute); }
}
</source>