public static object GetInstanceFieldOrProperty(object target, string fieldName)
{
Type t = target.GetType();
FieldInfo field = GetField(t, fieldName, false);
if (field != null)
return Reflector.prepRet(field.FieldType,field.GetValue(target));
PropertyInfo prop = GetProperty(t, fieldName, false);
if (prop != null)
return Reflector.prepRet(prop.PropertyType,prop.GetValue(target, new object[0]));
MethodInfo method = GetArityZeroMethod(t, fieldName, false);
if (method != null)
return Reflector.prepRet(method.ReturnType, method.Invoke(target, new object[0]));
throw new ArgumentException(String.Format("No matching instance field/property found: {0} for {1}", fieldName, t));
}