DescriptionAttribute.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // System.ComponentModel.DescriptionAttribute.cs
  3. //
  4. // Authors:
  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. {
  16. private string desc;
  17. public static readonly DescriptionAttribute Default = new DescriptionAttribute ();
  18. public DescriptionAttribute ()
  19. {
  20. desc = string.Empty;
  21. }
  22. public DescriptionAttribute (string name)
  23. {
  24. desc = name;
  25. }
  26. public virtual string Description {
  27. get {
  28. return DescriptionValue;
  29. }
  30. }
  31. //
  32. // Notice that the default Description implementation uses this by default
  33. //
  34. protected string DescriptionValue {
  35. get {
  36. return desc;
  37. }
  38. set {
  39. desc = value;
  40. }
  41. }
  42. public override bool Equals (object obj)
  43. {
  44. if (!(obj is DescriptionAttribute))
  45. return false;
  46. if (obj == this)
  47. return true;
  48. return ((DescriptionAttribute) obj).Description == desc;
  49. }
  50. public override int GetHashCode ()
  51. {
  52. return desc.GetHashCode ();
  53. }
  54. }
  55. }