Difference between revisions of "AttributeInfo"

From Xojo Documentation

m
Line 17: Line 17:
 
Add attributes to project items, methods, properties, constants, etc. by using the "Advanced" tab on the Inspector.
 
Add attributes to project items, methods, properties, constants, etc. by using the "Advanced" tab on the Inspector.
  
==Examples==
+
== Sample Code ==
 
Suppose Window1 has three attributes: The first attribute contains the Name only and the others have both a Name and Value:
 
Suppose Window1 has three attributes: The first attribute contains the Name only and the others have both a Name and Value:
 
{| class="genericTable"
 
{| class="genericTable"
 
 
! width=10% | Name
 
! width=10% | Name
 
 
! width=10% | Value
 
! width=10% | Value
 
|-
 
|-
 
|myName1
 
|myName1
 
 
|
 
|
 
|-
 
|-
 
|myName2
 
|myName2
 
 
|"Foo"
 
|"Foo"
 
 
|-
 
|-
 
|myName3
 
|myName3
 
 
|23
 
|23
 
 
|-
 
|-
 
|}
 
|}
Line 56: Line 49:
  
 
==See Also==
 
==See Also==
[[ConstructorInfo]], [[MemberInfo]], [[MethodInfo]], [[ObjectIterator]], [[ParameterInfo]], [[PropertyInfo]], [[TypeInfo]] classes; [[Introspection]] module; [[GetTypeInfo]] function.
+
[[ConstructorInfo]], [[MemberInfo]], [[MethodInfo]], [[ObjectIterator]], [[ParameterInfo]], [[PropertyInfo]], [[TypeInfo]] classes; [[Introspection]] module; [[GetTypeInfo]] function; [[Xojo.Introspection]] namespace
 
 
[http://developer.xojo.com/xojo-introspection-attributeinfo Xojo.Introspection.AttributeInfo]
 
  
 
[[Category:Language_Classes]]
 
[[Category:Language_Classes]]
 
[[Category:Language_Introspection]]
 
[[Category:Language_Introspection]]

Revision as of 21:31, 21 January 2019

Class (inherits from MemberInfo)

Provides information on the attributes of an item via the Introspection system. Attributes are added to project items using the Inspector.

Properties
IsPrivate fa-lock-32.png IsPublic fa-lock-32.png Value
IsProtected fa-lock-32.png Name fa-lock-32.png

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:

Dim myAttributes() As Introspection.AttributeInfo = Introspection.GetType(Window1).GetAttributes

For i As Integer = 0 To UBound(myAttributes)
ListBox1.AddRow(myAttributes(i).Name)
If (myAttributes(i).Value.IsNull) Then
ListBox1.Cell(ListBox1.LastIndex, 1) = "No Value"
Else
ListBox1.Cell(ListBox1.LastIndex, 1) = Str(myAttributes(i).Value)
End If
Next

See Also

ConstructorInfo, MemberInfo, MethodInfo, ObjectIterator, ParameterInfo, PropertyInfo, TypeInfo classes; Introspection module; GetTypeInfo function; Xojo.Introspection namespace