code_junkie

How do I tell if a class property has a public set (.NET)?

Nov 11th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public string Log
  2. {
  3. get { return log; }
  4. protected set
  5. {
  6. if (log != value)
  7. {
  8. MarkModified(PropertyNames.Log, log);
  9. log = value;
  10. }
  11. }
  12.  
  13. }
  14.  
  15. PropertyInfo pi = ReflectionHelper.GetPropertyInfo(boundObjectType, sourceProperty);
  16.  
  17. if (!pi.CanWrite)
  18. SetReadOnlyCharacteristics(boundEditor);
  19.  
  20. PropertyInfo property = type.GetProperty("MyProperty", BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.Instance);
Add Comment
Please, Sign In to add comment