Reflection: how to omit inherited members.

  • Thread starter Thread starter Philipp Schumann
  • Start date Start date
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
 
Ah, MethodInfo.GetBaseDefinition seems the key here, I guess I will have to
use that for PropertyInfo.GetGetMethod and PropertyInfo.GetSetMethod...
 
Back
Top