I have this:
public string Log { get { return log; } protected set { if (log != value) { MarkModified(PropertyNames.Log, log); log = value; } } }
And my utility class for databinding does this:
PropertyInfo pi = ReflectionHelper.GetPropertyInfo(boundObjectType, sourceProperty); if (!pi.CanWrite) SetReadOnlyCharacteristics(boundEditor);
But PropertyInfo.CanWrite does not care whether the set is publicly accessible, only that it exists.
How can I determine if there’s a public set, not just any set?
An alternative to the suggested changes to ReflectionHelper in other answers is to call
pi.GetSetMethod(false)and see if the result is null.