BindableAttribute.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // System.ComponentModel.BindableAttribute.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // Copyright (C) Tim Coleman, 2002
  9. // (C) 2003 Andreas Nahr
  10. //
  11. //
  12. namespace System.ComponentModel {
  13. [AttributeUsage (AttributeTargets.All)]
  14. public sealed class BindableAttribute : Attribute {
  15. #region Fields
  16. //BindableSupport flags;
  17. private bool bindable;
  18. #endregion // Fields
  19. public static readonly BindableAttribute No = new BindableAttribute (BindableSupport.No);
  20. public static readonly BindableAttribute Yes = new BindableAttribute (BindableSupport.Yes);
  21. public static readonly BindableAttribute Default = new BindableAttribute (BindableSupport.Default);
  22. #region Constructors
  23. public BindableAttribute (BindableSupport flags)
  24. {
  25. //this.flags = flags;
  26. if (flags == BindableSupport.No)
  27. this.bindable = false;
  28. if (flags == BindableSupport.Yes || flags == BindableSupport.Default)
  29. this.bindable = true;
  30. }
  31. public BindableAttribute (bool bindable)
  32. {
  33. this.bindable = bindable;
  34. }
  35. #endregion // Constructors
  36. #region Properties
  37. public bool Bindable {
  38. get { return bindable; }
  39. }
  40. #endregion // Properties
  41. #region Methods
  42. public override bool Equals (object obj)
  43. {
  44. if (!(obj is BindableAttribute))
  45. return false;
  46. if (obj == this)
  47. return true;
  48. return ((BindableAttribute) obj).Bindable == bindable;
  49. }
  50. public override int GetHashCode ()
  51. {
  52. return bindable.GetHashCode ();
  53. }
  54. public override bool IsDefaultAttribute ()
  55. {
  56. return bindable == BindableAttribute.Default.Bindable;
  57. }
  58. #endregion // Methods
  59. }
  60. }