2009-06-22 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System / System.ComponentModel / CustomTypeDescriptor.cs
1 //
2 // System.ComponentModel.CustomTypeDescriptor
3 //
4 // Authors:             
5 //              Ivan N. Zlatev (contact i-nZ.net)
6 //
7 // (C) 2007 Ivan N. Zlatev
8
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 #if NET_2_0
31
32 using System;
33
34 namespace System.ComponentModel
35 {
36
37         public abstract class CustomTypeDescriptor : ICustomTypeDescriptor
38         {
39
40                 private ICustomTypeDescriptor _parent;
41                 
42                 protected CustomTypeDescriptor ()
43                 {
44                 }
45
46                 
47                 protected CustomTypeDescriptor (ICustomTypeDescriptor parent)
48                 {
49                         _parent = parent;
50                 }
51
52
53                 public virtual AttributeCollection GetAttributes ()
54                 {
55                         if (_parent != null)
56                                 return _parent.GetAttributes ();
57
58                         return AttributeCollection.Empty;
59                 }
60
61
62                 public virtual string GetClassName ()
63                 {
64                         if (_parent != null)
65                                 return _parent.GetClassName ();
66
67                         return null;
68                 }
69
70
71                 public virtual string GetComponentName ()
72                 {
73                         if (_parent != null)
74                                 return _parent.GetComponentName ();
75
76                         return null;
77                 }
78
79
80                 public virtual TypeConverter GetConverter ()
81                 {
82                         if (_parent != null)
83                                 return _parent.GetConverter ();
84
85                         return new TypeConverter();
86                 }
87
88
89                 public virtual EventDescriptor GetDefaultEvent()
90                 {
91                         if (_parent != null)
92                                 return _parent.GetDefaultEvent ();
93                         
94                         return null;
95                 }
96
97
98                 public virtual PropertyDescriptor GetDefaultProperty ()
99                 {
100                         if (_parent != null)
101                                 return _parent.GetDefaultProperty ();
102                         
103                         return null;
104                 }
105
106                 
107                 public virtual object GetEditor (Type editorBaseType)
108                 {
109                         if (_parent != null)
110                                 return _parent.GetEditor (editorBaseType);
111
112                         return null;
113                 }
114
115
116                 public virtual EventDescriptorCollection GetEvents ()
117                 {
118                         if (_parent != null)
119                                 return _parent.GetEvents ();
120                         
121                         return EventDescriptorCollection.Empty;
122                 }
123
124  
125                 public virtual EventDescriptorCollection GetEvents (Attribute[] attributes)
126                 {
127                         if (_parent != null)
128                                 return _parent.GetEvents(attributes);
129                         
130                         return EventDescriptorCollection.Empty;
131                 }
132
133  
134                 public virtual PropertyDescriptorCollection GetProperties ()
135                 {
136                         if (_parent != null)
137                                 return _parent.GetProperties ();
138                         
139                         return PropertyDescriptorCollection.Empty;
140                 }
141
142                 
143                 public virtual PropertyDescriptorCollection GetProperties (Attribute[] attributes)
144                 {
145                         if (_parent != null)
146                                 return _parent.GetProperties (attributes);
147                         
148                         return PropertyDescriptorCollection.Empty;
149                 }
150
151
152                 public virtual object GetPropertyOwner (PropertyDescriptor pd)
153                 {
154                         if (_parent != null)
155                                 return _parent.GetPropertyOwner (pd);
156                         
157                         return null;
158                 }
159                 
160         }
161         
162 }
163
164 #endif