One way retrieve the accessibility accessors on PropertyInfo
is
bool HasPublicGetter (PropertyInfo pi)
{
if (!pi.CanRead)
return false;
MethodInfo getter = pi.GetMethod;
return getter.IsPublic;
}
Same applies to EventInfo
with AddMethod
.
It all make sense, as properties aren't public or private by themselves, but have public or private getters and setters.