2002-01-05 Ravi Pratap <ravi@ximian.com>
[mono.git] / mcs / class / System / System.ComponentModel / MemberDescriptor.cs
1 //
2 // System.ComponentModel.MemberDescriptor.cs
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9
10 namespace System.ComponentModel {
11
12         public class MemberDescriptor {
13                 string name;
14                 Attribute [] attrs;
15                 
16                 protected MemberDescriptor (string name, Attribute [] attrs)
17                 {
18                         this.name = name;
19                         this.attrs = attrs;
20                 }
21
22                 protected MemberDescriptor (MemberDescriptor reference, Attribute [] attrs)
23                 {
24                         name = reference.name;
25                         this.attrs = attrs;
26                 }
27
28                 protected MemberDescriptor (string name)
29                 {
30                         this.name = name;
31                 }
32
33                 protected MemberDescriptor (MemberDescriptor reference)
34                 {
35                         name = reference.name;
36                         attrs = reference.attrs;
37                 }
38
39                 protected virtual Attribute [] AttributeArray {
40                         get {
41                                 return attrs;
42                         }
43
44                         set {
45                                 attrs = value;
46                         }
47                 }
48
49                 // FIXME: Implement Attributes property
50                 [MonoTODO ("Implement Attributes property too")]
51                 public virtual string Category {
52                         get {
53                                 foreach (Attribute attr in attrs){
54
55
56
57                                         if (attr is CategoryAttribute){
58                                                 return ((CategoryAttribute) attr).Category;
59                                         }
60                                 }
61                                 return "Misc";
62                         }
63                 }
64
65                 public virtual string Description {
66                         get {
67                                 foreach (Attribute attr in attrs){
68                                         if (attr is DescriptionAttribute)
69                                                 return ((DescriptionAttribute) attr).Description;
70                                 }
71
72                                 return "";
73                         }
74                 }
75
76                 public virtual bool DesignTimeOnly {
77                         get {
78                                 foreach (Attribute attr in attrs){
79                                         if (attr is DesignOnlyAttribute)
80                                                 return ((DesignOnlyAttribute) attr).IsDesignOnly;
81                                 }
82
83                                 return false;
84                         }
85                 }
86
87                 //
88                 // FIXME: Is there any difference between DisplayName and Name?
89                 //
90                 [MonoTODO ("Does this diff from Name ?")]
91                 public virtual string DisplayName {
92                         get {
93                                 return name;
94                         }
95                 }
96
97                 public virtual string Name {
98                         get {
99                                 return name;
100                         }
101                 }
102
103                 public virtual bool IsBrowsable {
104                         get {
105                                 foreach (Attribute attr in attrs){
106                                         if (attr is BrowsableAttribute)
107                                                 return ((BrowsableAttribute) attr).Browsable;
108                                 }
109
110                                 return false;
111                         }
112                 }
113
114                 protected virtual int NameHashCode {
115                         get {
116                                 return name.GetHashCode ();
117                         }
118                 }
119         }
120 }