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