473,568 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetPropert ies(), 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_*******@nospa m.hotmail.com
Jul 21 '05 #1
2 1988
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.De claredOnly), 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.De claredOnly), and manually walk the inheritance
hierarchy.

Mattias

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7347
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a Windows.Forms.UserControl in a COM environment, i.e. I want to host that control in a COM host. So far, so good, I can host it, but I can not reach the...
2
5230
by: Jim Heavey | last post by:
I want to write a routine which will list all of the propetries and all property names for a particular object, say a DataColumn. I there a way for me to do this without manually looking up each property name and the property value? Thanks in advance for your assistance!!!!!!!!!!!
3
1546
by: Andrey | last post by:
Hi, Here's the problem: Say a have a class, implementing an interface: // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv public class GraphClass : IGraphInterface { public string Property1 { get {
1
1276
by: Dave Wurtz | last post by:
All, Is it possible to get all of the current namespaces that are available through reflection? What I am trying to do is get back all of the namespaces, then classes within the namespaces, then methods/properties within the classes. I need each one separated - like VS.NET's intellisense. I'm trying to get all of this information from...
8
1654
by: Joel Reinford | last post by:
I would like to build a class that has properties which can be accessed by string names or index numbers in the form of MyClass.Item("LastName"). The string names or item index values would be populated by a data-driven loop. I need a few pointers to get me started in the right direction. I'm pretty sure that I need a default Item property...
2
350
by: Dawid Mostert | last post by:
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.
9
6803
by: Don | last post by:
Say I have a class like so: Public Class MyClass Public Prop1 as Integer Public Prop2 As Integer Public Prop3 As Integer End Class Is it possible to retrieve a list of the variables or objects declared within an instance of that class if they are declared with Public (or
4
2798
by: Cedric Rogers | last post by:
I wasn't sure if I could do this. I believe I am stretching the capability of what generics can do for me but here goes. I have a generic delegate defined as public delegate bool RuleDelegate<T>(T item); In my class my goal is to use a generic list collection to contain my generic delegates. This will allow me to pass this List to...
5
1273
by: JS | last post by:
There are 2 features that I keep wishing C# had. These are not groundbreaking ideas, and I haven't given these too much thought, but I wonder if others have also wanted these types of language features. 1. C# Keywords for reflection. The idea here is that we can access PropertyInfo through a keyword. An example might be: PropertyInfo...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.