Implement MachineKey.Protect and MachineKey.Unprotect
[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 using System;
31
32 namespace System.ComponentModel
33 {
34
35         public abstract class CustomTypeDescriptor : ICustomTypeDescriptor
36         {
37
38                 private ICustomTypeDescriptor _parent;
39                 
40                 protected CustomTypeDescriptor ()
41                 {
42                 }
43
44                 
45                 protected CustomTypeDescriptor (ICustomTypeDescriptor parent)
46                 {
47                         _parent = parent;
48                 }
49
50
51                 public virtual AttributeCollection GetAttributes ()
52                 {
53                         if (_parent != null)
54                                 return _parent.GetAttributes ();
55
56                         return AttributeCollection.Empty;
57                 }
58
59
60                 public virtual string GetClassName ()
61                 {
62                         if (_parent != null)
63                                 return _parent.GetClassName ();
64
65                         return null;
66                 }
67
68
69                 public virtual string GetComponentName ()
70                 {
71                         if (_parent != null)
72                                 return _parent.GetComponentName ();
73
74                         return null;
75                 }
76
77
78                 public virtual TypeConverter GetConverter ()
79                 {
80                         if (_parent != null)
81                                 return _parent.GetConverter ();
82
83                         return new TypeConverter();
84                 }
85
86
87                 public virtual EventDescriptor GetDefaultEvent()
88                 {
89                         if (_parent != null)
90                                 return _parent.GetDefaultEvent ();
91                         
92                         return null;
93                 }
94
95
96                 public virtual PropertyDescriptor GetDefaultProperty ()
97                 {
98                         if (_parent != null)
99                                 return _parent.GetDefaultProperty ();
100                         
101                         return null;
102                 }
103
104                 
105                 public virtual object GetEditor (Type editorBaseType)
106                 {
107                         if (_parent != null)
108                                 return _parent.GetEditor (editorBaseType);
109
110                         return null;
111                 }
112
113
114                 public virtual EventDescriptorCollection GetEvents ()
115                 {
116                         if (_parent != null)
117                                 return _parent.GetEvents ();
118                         
119                         return EventDescriptorCollection.Empty;
120                 }
121
122  
123                 public virtual EventDescriptorCollection GetEvents (Attribute[] attributes)
124                 {
125                         if (_parent != null)
126                                 return _parent.GetEvents(attributes);
127                         
128                         return EventDescriptorCollection.Empty;
129                 }
130
131  
132                 public virtual PropertyDescriptorCollection GetProperties ()
133                 {
134                         if (_parent != null)
135                                 return _parent.GetProperties ();
136                         
137                         return PropertyDescriptorCollection.Empty;
138                 }
139
140                 
141                 public virtual PropertyDescriptorCollection GetProperties (Attribute[] attributes)
142                 {
143                         if (_parent != null)
144                                 return _parent.GetProperties (attributes);
145                         
146                         return PropertyDescriptorCollection.Empty;
147                 }
148
149
150                 public virtual object GetPropertyOwner (PropertyDescriptor pd)
151                 {
152                         if (_parent != null)
153                                 return _parent.GetPropertyOwner (pd);
154                         
155                         return null;
156                 }
157                 
158         }
159         
160 }
161