With Type.GetProperties()
you can retrieve all properties of your current class and the public
properties of the base-class. Is it somehow possible
Iterate through the base types (type = type.BaseType), until type.BaseType is null.
MethodInfo mI = null;
Type baseType = someObject.GetType();
while (mI == null)
{
mI = baseType.GetMethod("SomePrivateMethod", BindingFlags.NonPublic | BindingFlags.Instance);
baseType = baseType.BaseType;
if (baseType == null) break;
}
mI.Invoke(someObject, new object[] {});
To get all properties (public + private/protected/internal, static + instance) of a given Type someType
(maybe using GetType()
to get someType
):
PropertyInfo[] props = someType.BaseType.GetProperties(
BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance | BindingFlags.Static)