public object InvokeMethod(object target, string methodName, params object[] args)
{
Type t = target.GetType();
MethodInfo mi = null;
while (t != null)
{
mi = t.GetMethod (methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (mi != null) break;
t = t.BaseType;
}
if (mi == null)
{
throw new Exception(string.Format("Method '{0}' not found in type hierarchy.", methodName));
}
return mi.Invoke (target, args);
}