Reflection: how to omit inherited members.

P

Philipp Schumann

Hello,

I obtain the properties of a Type t through
Type.GetProperties(BindingFlags). I use the following flags:

BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic |
BindingFlags.Public

Now, some of the returned properties are actually overriding properties from
a base class, and I would like to find out whether there is a simple way to
filter these out (other than comparing the types and names of all properties
of all base types). Surely there is an internal flag "overrides" set
anywhere anyway, and I just didn't manage to find that yet.

Any ideas?
Thanks,
Phil
 
P

Philipp Schumann

Ah, MethodInfo.GetBaseDefinition seems the key here, I guess I will have to
use that for PropertyInfo.GetGetMethod and PropertyInfo.GetSetMethod...
 

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