DesignerCategoryAttribute.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // System.ComponentModel.DesignerCategoryAttribute.cs
  3. //
  4. // Author:
  5. // Alan Tam Siu Lung ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2003 Andreas Nahr
  9. //
  10. namespace System.ComponentModel {
  11. /// <summary>
  12. /// Designer Attribute for classes.
  13. /// </summary>
  14. /// <remarks>
  15. /// </remarks>
  16. [AttributeUsage(AttributeTargets.Class)]
  17. public sealed class DesignerCategoryAttribute : Attribute
  18. {
  19. private string category;
  20. public static readonly DesignerCategoryAttribute Component = new DesignerCategoryAttribute ("Component");
  21. public static readonly DesignerCategoryAttribute Form = new DesignerCategoryAttribute ("Form");
  22. public static readonly DesignerCategoryAttribute Generic = new DesignerCategoryAttribute ("Designer");
  23. public static readonly DesignerCategoryAttribute Default = new DesignerCategoryAttribute ("");
  24. public DesignerCategoryAttribute ()
  25. {
  26. this.category = "";
  27. }
  28. public DesignerCategoryAttribute (string category)
  29. {
  30. this.category = category;
  31. }
  32. public override object TypeId {
  33. get {
  34. return GetType ();
  35. }
  36. }
  37. public string Category {
  38. get {
  39. return category;
  40. }
  41. }
  42. public override bool Equals (object obj)
  43. {
  44. if (!(obj is DesignerCategoryAttribute))
  45. return false;
  46. if (obj == this)
  47. return true;
  48. return ((DesignerCategoryAttribute) obj).Category == category;
  49. }
  50. public override int GetHashCode ()
  51. {
  52. return category.GetHashCode ();
  53. }
  54. public override bool IsDefaultAttribute ()
  55. {
  56. return category == DesignerCategoryAttribute.Default.Category;
  57. }
  58. }
  59. }