Module.GetCustomAttributes Method (Boolean)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Returns all custom attributes.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Overridable Function GetCustomAttributes ( _ inherit As Boolean _ ) As Object()
Parameters
- inherit
- Type: System.Boolean
This argument is ignored for objects of this type.
Implements
ICustomAttributeProvider.GetCustomAttributes(Boolean)The following example defines an attribute and applies it to the example's module. When the example runs, it retrieves the attributes that were applied to the module and displays them.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
Imports System.Reflection ' Define a module-level attribute. <Module: MySimpleAttribute("module-level")> Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) Dim moduleArray() As [Module] = _ [Assembly].GetExecutingAssembly().GetModules() Dim myModule As [Module] = moduleArray(0) Dim attributes() As Object = myModule.GetCustomAttributes(True) For Each o As Object In attributes outputBlock.Text &= _ String.Format("Found this attribute on myModule: {0}" & vbLf, o.ToString()) Next o End Sub End Class 'A very simple custom attribute. <AttributeUsage(AttributeTargets.Class Or AttributeTargets.Module)> _ Public Class MySimpleAttribute Inherits Attribute Private name As String Public Sub New(ByVal newName As String) name = newName End Sub End Class ' This example produces output similar to the following: ' 'Found this attribute on myModule: SilverlightApplication.MySimpleAttribute.
Show:
Note: