Get a property's attribute through introspection : Is it possible?

Hi everyone,

I’m trying to get a custom property’s attributes using the introspection class but I get an empty array.

What I want to do is to link the data I stored in an array to Web Labels by matching the their indexes and names. For exemple,

Database.table.fields() = “info1”, “info2”,…
Array() = (info1data, info2data,…)
Container1.WebLabels.names : “WLinfo1”, “WLinfo2”, … (Table field “info1” data has to be placed in the label WLinfo1 and so on)
Container1.properties: “pInfo1”, pInfo2" have attribute for each field called “fieldIndex” corresponding to the field index in the array

Exemple with Field “Info1”

1- I go through My container’s labels collection and I retrieve the name (“WLinfo1”),
2- I match the name with the property(“pInfo1”)
3- Finally, I want to get the “fieldIndex” attribute’s value (which would be 0 as the “info1” is the first value in the array) to pick the right data in the array …

but the attributes array is empty : (Dim propAttributes() As Introspection.AttributeInfo = Introspection.GetType(propList(j)).GetAttributes

Here is my code :

Dim propList() As Introspection.PropertyInfo = Introspection.GetType(WLSubToPopulate).GetProperties For j As Integer = 0 To Ubound(propList) If propList(j).Name = propertyName Then Dim propAttributes() As Introspection.AttributeInfo = Introspection.GetType(propList(j)).GetAttributes For k As Integer = 0 To UBound(propAttributes) If propAttributes(k).Name = "fieldIndex" Then Return Cint(WLSubData(WLSubCount, propAttributes(k).Value)) End If Next k End If Next j

So what am I doing wrong?

This line is in error. It is getting the attributes of the PropertyInfo object that refers to the property you want. Call GetAttributes on propList(j) directly:

Dim propAttributes() As Introspection.AttributeInfo = propList(j).GetAttributes

Right on! Thanks!