public static MethodInfo GetArityZeroMethod(Type t, string name, bool getStatics)
{
BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod;
if (getStatics)
flags |= BindingFlags.Static;
else
flags |= BindingFlags.Instance;
//MethodInfo[] all = t.GetMethods();
IEnumerable<MethodInfo> einfo = t.GetMethods(flags).Where(mi => mi.Name == name && mi.GetParameters().Length == 0);
List<MethodInfo> infos = new List<MethodInfo>(einfo);
if (infos.Count() == 1)
return infos[0];
else
return null;
}