EditorAttribute.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // System.ComponentModel.EditorAttribute.cs
  3. //
  4. // Author:
  5. // Alejandro Sánchez Acosta ([email protected])
  6. //
  7. // (C) Alejandro Sánchez Acosta
  8. //
  9. namespace System.ComponentModel {
  10. /// <summary>
  11. /// Editor Attribute for classes.
  12. /// </summary>
  13. [AttributeUsage (AttributeTargets.All)]
  14. public sealed class EditorAttribute : Attribute {
  15. string name;
  16. string basename;
  17. Type baseType;
  18. Type nametype;
  19. public EditorAttribute ()
  20. {
  21. this.name = "";
  22. }
  23. public EditorAttribute (string typeName, string baseTypeName)
  24. {
  25. name = typeName;
  26. basename = baseTypeName;
  27. }
  28. public EditorAttribute (string typeName, Type baseType)
  29. {
  30. name = typeName;
  31. this.baseType = baseType;
  32. }
  33. public EditorAttribute (Type type, Type baseType)
  34. {
  35. nametype = type;
  36. this.baseType = baseType;
  37. }
  38. public string EditorBaseTypeName {
  39. get {
  40. return basename;
  41. }
  42. }
  43. public string EditorTypeName {
  44. get {
  45. return name;
  46. }
  47. }
  48. public override object TypeId {
  49. get {
  50. return this.GetType ();
  51. }
  52. }
  53. public override bool Equals (object obj)
  54. {
  55. if (!(obj is EditorAttribute))
  56. return false;
  57. return (((EditorAttribute) obj).name == name) &&
  58. (((EditorAttribute) obj).basename == basename) &&
  59. (((EditorAttribute) obj).baseType == baseType) &&
  60. (((EditorAttribute) obj).nametype == nametype);
  61. }
  62. public override int GetHashCode ()
  63. {
  64. if (name == null)
  65. return 0;
  66. return name.GetHashCode ();
  67. }
  68. }
  69. }