Class
AttributeInfo
Description
Provides information on the attributes of an item via the Introspection system. Attributes are added to project items using the Inspector.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
AttributeInfo |
Property descriptions
AttributeInfo.IsPrivate
IsPrivate As Boolean
If True, the item has Private scope.
This property is read-only.
The following example checks the IsPrivate property before taking an action.
Var d As New DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
If prop.IsPrivate Then
// take an action here..
End If
Next
AttributeInfo.IsProtected
IsProtected As Boolean
Is True, the item has Protected scope.
This property is read-only.
Var d As New DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
If prop.IsProtected Then
// take an action here..
End If
Next
AttributeInfo.IsPublic
IsPublic As Boolean
If True, the item has Public scope.
This property is read-only.
This example checks the IsPublic property before taking an action.
Var d As New DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
If prop.IsPublic Then
// take an action here..
End If
Next
AttributeInfo.Name
Name As String
The name of the item. This is only the class name. To get the full namespace path, use FullName instead.
This property is read-only.
This code gets the list of properties for the passed type instance.
Var d As DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
ListBox1.AddRow(prop.Name)
Next
AttributeInfo.Value
Value As Variant
The optional value of the attribute.
Suppose Window1 has three attributes: The first attribute contains the Name only and the others have both a Name and Value:
Name |
Value |
---|---|
myName1 |
|
myName2 |
"Foo" |
myName3 |
23 |
The following code retrieves the attributes and displays them in a ListBox:
For Each attribute As Introspection.AttributeInfo In Introspection.GetType(window1).GetAttributes
ListBox1.AddRow attribute.Name
If attribute.Value.IsNull Then
ListBox1.CellTextAt(ListBox1.LastAddedRowIndex,1) = "No Value"
Else
ListBox1.CellTextAt(ListBox1.LastAddedRowIndex,1) = attribute.Value
End If
Next
Method descriptions
AttributeInfo.GetAttributes
GetAttributes As AttributeInfo
Returns an array of AttributeInfo objects.
The following gets the attributes of window1.
Var myAttributes() As Introspection.AttributeInfo = Introspection.GetType(Window1).GetAttributes
Notes
For attributes of classes, attributes are inherited from the parent class and attribute values are overridden if redefined by the subclass.
Add attributes to project items, methods, properties, constants, etc. by using the "Advanced" tab on the Inspector.
Sample code
Suppose Window1 has three attributes: The first attribute contains the Name only and the others have both a Name and Value:
Name |
Value |
---|---|
myName1 |
|
myName2 |
"Foo" |
myName3 |
23 |
The following code retrieves the attributes and displays them in a ListBox:
For Each attribute As Introspection.AttributeInfo In Introspection.GetType(window1).GetAttributes
ListBox1.AddRow attribute.Name
If attribute.Value.IsNull Then
ListBox1.CellTextAt(ListBox1.LastAddedRowIndex,1) = "No Value"
Else
ListBox1.CellTextAt(ListBox1.LastAddedRowIndex,1) = attribute.Value
End If
Next
Compatibility
All project types on all supported operating systems.
See also
MemberInfo parent class; ConstructorInfo, MemberInfo, MethodInfo, ObjectIterator, ParameterInfo, PropertyInfo, TypeInfo classes; Introspection module; GetTypeInfo function; Introspection namespace