471,348 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Getting list of Properties using Reflection

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
d_*******@nospam.hotmail.com
Jul 21 '05 #1
2 1826
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
Thanks!

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

How do I combine 2 arrays into 1?

Regards,
Dawid

Mattias Sjögren wrote:
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

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jim Heavey | last post: by
2 posts views Thread by Dawid Mostert | last post: by
4 posts views Thread by Cedric Rogers | last post: by
5 posts views Thread by JS | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.