b9269cf2517d2605470ee0f2e76121b4ba12d08a
[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 //
7 // (C) Alejandro Sánchez Acosta
8 //
9
10 namespace System.ComponentModel {
11
12         /// <summary>
13         ///   Editor Attribute for classes. 
14         /// </summary>
15
16         [AttributeUsage (AttributeTargets.All)]
17         public sealed class EditorAttribute : Attribute {
18                 
19                 string name;    
20                 string basename;
21                 Type baseType;
22                 Type nametype;
23
24                 public EditorAttribute ()
25                 {
26                         this.name = "";
27                 }
28
29                 public EditorAttribute (string typeName, string baseTypeName)
30                 {
31                         name = typeName;
32                         basename = baseTypeName;
33                 }
34
35                 public EditorAttribute (string typeName, Type baseType)
36                 {
37                         name = typeName;
38                         this.baseType = baseType;       
39                 }
40
41                 public EditorAttribute (Type type, Type baseType)
42                 {
43                         nametype = type;
44                         this.baseType = baseType;
45                 }
46
47                 public string EditorBaseTypeName {
48                         get {
49                                 return basename;
50                         }
51                 }
52                 
53                 public string EditorTypeName {
54                         get {
55                                 return name;
56                         }
57                 }
58
59                 public override object TypeId {
60                         get {
61                                 return this.GetType ();
62                         }
63                 }
64                 
65                 public override bool Equals (object o)
66                 {
67                         if (!(obj is EditorAttribute))
68                                 return false;
69
70                         return (((EditorAttribute) obj).name == name) &&
71                                 (((EditorAttribute) obj).basename == basename) &&
72                                 (((EditorAttribute) obj).baseType == baseType) &&
73                                 (((EditorAttribute) obj).nametype == nametype);
74
75                 }
76                 
77                 public override int GetHashCode ()
78                 {
79                         if (name == null)
80                                 return 0;
81
82                         return name.GetHashCode ();
83                 }
84         }
85 }