Getting list of Properties using Reflection

  • Thread starter Thread starter Dawid Mostert
  • Start date Start date
D

Dawid Mostert

Hi,

I'm trying to get a list of properties from a hierarchy of classes,
using reflection.

Using Type.GetProperties(), I get the list back in "reverse hierarchy
order" (derived class properties before parent class properties)

Using TypeDescriptor.GetProperties(), the order of the returned
properties is also wrong.

I used the XmlSerializer to test my classes, and the properties was
written out correctly (Parent class before derived class).

What can I do to get a list of properties in the correct order (Parent
class before inherited class)?

Thanks for the help,
Dawid Mostert
(e-mail address removed)
 
What can I do to get a list of properties in the correct order (Parent
class before inherited class)?

Get only the properties that are declared in the class itself (specify
BindingFlags.DeclaredOnly), and manually walk the inheritance
hierarchy.



Mattias
 
Thanks!

Sounds like a good idea... Any other (less manual ;) ) options?

How do I combine 2 arrays into 1?

Regards,
Dawid
 
Back
Top