mardi 14 juin 2016

Reflection Get Child Object Properties

Public Class MainClass
    Public Property ColorMode() As ColorMode
    Public Property OriginalSource() As OriginalSource
End Class

Public Class ColorMode
    Inherits ElementWithList
End Class

Public Class OriginalSource
    Inherits ElementWithList
End Class

Public Class ElementWithList
    Public Overridable Property type() As String
    Public Overridable Property minOccurs() As Integer
    Public Overridable Property maxOccurs() As Integer
    Public Overridable Property list() As List(Of String)
    Public Property [default]() As String
End Class

My Code is the following...

Dim propertyInfos As Reflection.PropertyInfo()
propertyInfos = MainClass.GetType.GetProperties()

For Each propertyInfo As Reflection.PropertyInfo In propertyInfos
    tmp = propertyInfo.PropertyType.BaseType.Name
    Dim obj As Object
    Dim typ As Type = propertyInfo.PropertyType
Next

In the for each loop I want to get the colormode object out then next time I want to get the OriginalSource object out and so forth....anyone have ideas where I need to go with this code to get that information? I have tried propertyInfo.GetValue but that is not correct.





Aucun commentaire:

Enregistrer un commentaire