Getting list of Properties using Reflection

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)
 
M

Mattias Sjögren

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
 
D

Dawid Mostert

Thanks!

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

How do I combine 2 arrays into 1?

Regards,
Dawid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top