DesignerCategoryAttribute.cs 1.4 KB

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