MergablePropertyAttribute.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // System.ComponentModel.MergablePropertyAttribute
  3. //
  4. // Authors:
  5. // Martin Willemoes Hansen ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2003 Martin Willemoes Hansen
  9. // (C) 2003 Andreas Nahr
  10. //
  11. namespace System.ComponentModel
  12. {
  13. [AttributeUsage(AttributeTargets.All)]
  14. public sealed class MergablePropertyAttribute : Attribute
  15. {
  16. private bool mergable;
  17. public static readonly MergablePropertyAttribute Default = new MergablePropertyAttribute (true);
  18. public static readonly MergablePropertyAttribute No = new MergablePropertyAttribute (false);
  19. public static readonly MergablePropertyAttribute Yes = new MergablePropertyAttribute (true);
  20. public MergablePropertyAttribute (bool allowMerge)
  21. {
  22. this.mergable = allowMerge;
  23. }
  24. public bool AllowMerge {
  25. get { return mergable; }
  26. }
  27. public override bool Equals (object obj)
  28. {
  29. if (!(obj is MergablePropertyAttribute))
  30. return false;
  31. if (obj == this)
  32. return true;
  33. return ((MergablePropertyAttribute) obj).AllowMerge == mergable;
  34. }
  35. public override int GetHashCode()
  36. {
  37. return mergable.GetHashCode ();
  38. }
  39. public override bool IsDefaultAttribute()
  40. {
  41. return mergable == MergablePropertyAttribute.Default.AllowMerge;
  42. }
  43. }
  44. }