The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Module::GetCustomAttributes Method (Boolean)
.NET Framework (current version)
Returns all custom attributes.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- inherit
-
Type:
System::Boolean
This argument is ignored for objects of this type.
The following example displays the module names that match the specified search criteria.
using namespace System; using namespace System::Reflection; using namespace System::Collections; namespace ReflectionModule_Examples { //Define a module-level attribute. //A very simple custom attribute. [AttributeUsage(AttributeTargets::Class|AttributeTargets::Module)] public ref class MySimpleAttribute: public Attribute { private: String^ name; public: MySimpleAttribute( String^ newName ) { name = newName; } }; [module:MySimpleAttribute("module-level")]; ref class MyMainClass{}; } int main() { array<System::Reflection::Module^>^moduleArray; moduleArray = ReflectionModule_Examples::MySimpleAttribute::typeid->Assembly->GetModules( false ); // In a simple project with only one module, the module at index // 0 will be the module containing these classes. System::Reflection::Module^ myModule = moduleArray[ 0 ]; array<Object^>^attributes; attributes = myModule->GetCustomAttributes( true ); IEnumerator^ myEnum = attributes->GetEnumerator(); while ( myEnum->MoveNext() ) { Object^ o = safe_cast<Object^>(myEnum->Current); Console::WriteLine( "Found this attribute on myModule: {0}.", o ); } }
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Show: