ReadOnlyAttribute.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // ReadOnlyAttribute.cs
  3. //
  4. // Author:
  5. // Chris J Breisch ([email protected])
  6. //
  7. // (C) 2002 Chris J Breisch
  8. //
  9. namespace System.ComponentModel {
  10. [AttributeUsage (AttributeTargets.All)]
  11. sealed public class ReadOnlyAttribute : Attribute {
  12. bool read_only;
  13. public static readonly ReadOnlyAttribute No;
  14. public static readonly ReadOnlyAttribute Yes;
  15. public static readonly ReadOnlyAttribute Default;
  16. static ReadOnlyAttribute ()
  17. {
  18. No = new ReadOnlyAttribute (false);
  19. Yes = new ReadOnlyAttribute (true);
  20. Default = new ReadOnlyAttribute (false);
  21. }
  22. public ReadOnlyAttribute (bool read_only)
  23. {
  24. this.read_only = read_only;
  25. }
  26. public bool IsReadOnly {
  27. get {
  28. return read_only;
  29. }
  30. }
  31. public override int GetHashCode ()
  32. {
  33. return base.GetHashCode ();
  34. }
  35. public override bool Equals (object o)
  36. {
  37. if (!(o is ReadOnlyAttribute))
  38. return false;
  39. return (((ReadOnlyAttribute) o).read_only == read_only);
  40. }
  41. public override bool IsDefaultAttribute ()
  42. {
  43. return Equals (Default);
  44. }
  45. }
  46. }