DesignerCategoryAttribute.cs 1.5 KB

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