EditorAttribute.cs 1.5 KB

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