DescriptionAttribute.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // System.ComponentModel.DescriptionAttribute.cs
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) Ximian, Inc. http://www.ximian.com
  9. // (C) 2003 Andreas Nahr
  10. //
  11. //
  12. namespace System.ComponentModel {
  13. [AttributeUsage (AttributeTargets.All)]
  14. public class DescriptionAttribute : Attribute {
  15. private string desc;
  16. public static readonly DescriptionAttribute Default = new DescriptionAttribute ();
  17. public DescriptionAttribute ()
  18. {
  19. desc = "";
  20. }
  21. public DescriptionAttribute (string name)
  22. {
  23. desc = name;
  24. }
  25. public virtual string Description {
  26. get {
  27. return DescriptionValue;
  28. }
  29. }
  30. //
  31. // Notice that the default Description implementation uses this by default
  32. //
  33. protected string DescriptionValue {
  34. get {
  35. return desc;
  36. }
  37. set {
  38. desc = value;
  39. }
  40. }
  41. public override bool Equals (object obj)
  42. {
  43. if (!(obj is DescriptionAttribute))
  44. return false;
  45. if (obj == this)
  46. return true;
  47. return ((DescriptionAttribute) obj).Description == desc;
  48. }
  49. public override int GetHashCode ()
  50. {
  51. return desc.GetHashCode ();
  52. }
  53. }
  54. }