Iterating through unknown classes via reflection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andi23coe
    New Member
    • Mar 2008
    • 1

    Iterating through unknown classes via reflection

    Hello everybody!

    I have a problem with listing the properties of an unknown class via reflection so far.

    My class structure, automatically generated through linq to xsd:

    meeting
    --> VNR (string)
    --> membercount (string)
    --> member (ilist) (kind properties: name, telephonenumber

    I want to list all properties of the main class, then the properties of the ilist types (the properties of an instance, i.e. name, telephonenumber ), etc.

    My code:

    Dim help as new meeting

    For Each info in help.gettype.ge tproperties().t olist
    Messagebox.show (info.name.tost ring)
    Next


    This should be a recursive function, but I don't have any idea to "walk through the properties" of the ilist parameter (member) in this case of an empty meeting object. The results of the property list of the ilist property "member" are count, item, readonly, and not name or telephonenumber .

    In the case of readin the solution for me was:

    help.gettype.ge tmethod("get_me mber").invoke(h elp, nothing).gettyp e.getproperties .tolist
    ...

    But in this situation of an unknown object there aren't any results of this method, so I don't see a chance to read the properties.

    Any suggestions?

    Yours sincerely

    Andrè Döking
Working...