Add few 4.5 types to compile MEF2
[mono.git] / mcs / class / corlib / System.Reflection / TypeDelegator.cs
1 // System.Reflection/TypeDelegator.cs
2 //
3 // Paolo Molaro (lupus@ximian.com)
4 //
5 // (C) 2002 Ximian, Inc.
6
7 //
8 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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 using System.Reflection;
32 using System.Globalization;
33 using System.Runtime.InteropServices;
34
35 namespace System.Reflection {
36
37         [ComVisible (true)]
38         [Serializable]
39         public class TypeDelegator : 
40 #if NET_4_5
41                 TypeInfo, IReflectableType
42 #else
43                 Type
44 #endif
45         {
46                 protected Type typeImpl;
47         
48                 protected TypeDelegator () {
49                 }
50
51                 public TypeDelegator( Type delegatingType)
52                 {
53                         if (delegatingType == null)
54                                 throw new ArgumentNullException ("delegatingType must be non-null");
55                         typeImpl = delegatingType;
56                 }
57
58                 public override Assembly Assembly {
59                         get { return typeImpl.Assembly; }
60                 }
61
62                 public override string AssemblyQualifiedName {
63                         get { return typeImpl.AssemblyQualifiedName; }
64                 }
65
66                 public override Type BaseType {
67                         get { return typeImpl.BaseType; }
68                 }
69
70                 public override string FullName {
71                         get { return typeImpl.FullName; }
72                 }
73
74                 public override Guid GUID {
75                         get { return typeImpl.GUID; }
76                 }
77
78                 public override Module Module {
79                         get { return typeImpl.Module; }
80                 }
81
82                 public override string Name {
83                         get { return typeImpl.Name; }
84                 }
85
86                 public override string Namespace {
87                         get { return typeImpl.Namespace; }
88                 }
89
90                 public override RuntimeTypeHandle TypeHandle {
91                         get { return typeImpl.TypeHandle; }
92                 }
93
94                 public override Type UnderlyingSystemType {
95                         get { return typeImpl.UnderlyingSystemType; }
96                 }
97
98                 protected override TypeAttributes GetAttributeFlagsImpl ()
99                 {
100                         return typeImpl.Attributes;
101                 }
102                 
103                 protected override ConstructorInfo GetConstructorImpl (
104                         BindingFlags bindingAttr, Binder binder, CallingConventions callConvention,
105                         Type[] types, ParameterModifier[] modifiers)
106                 {
107                         return typeImpl.GetConstructor (bindingAttr, binder, callConvention, types, modifiers);
108                 }
109
110                 [ComVisible (true)]
111                 public override ConstructorInfo[] GetConstructors( BindingFlags bindingAttr)
112                 {
113                         return typeImpl.GetConstructors (bindingAttr);
114                 }
115
116                 public override object[] GetCustomAttributes (bool inherit)
117                 {
118                         return typeImpl.GetCustomAttributes (inherit);
119                 }
120
121                 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
122                 {
123                         return typeImpl.GetCustomAttributes (attributeType, inherit);
124                 }
125
126                 public override Type GetElementType()
127                 {
128                         return typeImpl.GetElementType ();
129                 }
130
131                 public override EventInfo GetEvent( string name, BindingFlags bindingAttr)
132                 {
133                         return typeImpl.GetEvent (name, bindingAttr);
134                 }
135
136                 public override EventInfo[] GetEvents()
137                 {
138                         return GetEvents (BindingFlags.Public);
139                 }
140
141                 public override EventInfo[] GetEvents (BindingFlags bindingAttr)
142                 {
143                         return typeImpl.GetEvents (bindingAttr);
144                 }
145
146                 public override FieldInfo GetField (string name, BindingFlags bindingAttr)
147                 {
148                         return typeImpl.GetField (name, bindingAttr);
149                 }
150
151                 public override FieldInfo[] GetFields( BindingFlags bindingAttr)
152                 {
153                         return typeImpl.GetFields (bindingAttr);
154                 }
155
156                 public override Type GetInterface( string name, bool ignoreCase)
157                 {
158                         return typeImpl.GetInterface (name, ignoreCase);
159                 }
160
161                 [ComVisible (true)]
162                 public override InterfaceMapping GetInterfaceMap( Type interfaceType)
163                 {
164                         return typeImpl.GetInterfaceMap (interfaceType);
165                 }
166                 
167                 public override Type[] GetInterfaces ()
168                 {
169                         return typeImpl.GetInterfaces ();
170                 }
171
172                 public override MemberInfo[] GetMember( string name, MemberTypes type, BindingFlags bindingAttr)
173                 {
174                         return typeImpl.GetMember (name, type, bindingAttr);
175                 }
176
177                 public override MemberInfo[] GetMembers( BindingFlags bindingAttr)
178                 {
179                         return typeImpl.GetMembers (bindingAttr);
180                 }
181
182                 protected override MethodInfo GetMethodImpl( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
183                 {
184                         // Can't call GetMethod since it makes restrictive argument checks
185                         return typeImpl.GetMethodImplInternal (name, bindingAttr, binder, callConvention, types, modifiers);
186                 }
187
188                 public override MethodInfo[] GetMethods( BindingFlags bindingAttr)
189                 {
190                         return typeImpl.GetMethods (bindingAttr);
191                 }
192
193                 public override Type GetNestedType( string name, BindingFlags bindingAttr)
194                 {
195                         return typeImpl.GetNestedType (name, bindingAttr);
196                 }
197
198                 public override Type[] GetNestedTypes( BindingFlags bindingAttr)
199                 {
200                         return typeImpl.GetNestedTypes (bindingAttr);
201                 }
202
203                 public override PropertyInfo[] GetProperties( BindingFlags bindingAttr)
204                 {
205                         return typeImpl.GetProperties (bindingAttr);
206                 }
207
208                 protected override PropertyInfo GetPropertyImpl( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
209                 {
210                         // Can't call GetProperty since it makes restrictive argument checks
211                         return typeImpl.GetPropertyImplInternal (name, bindingAttr, binder, returnType, types, modifiers);
212                 }
213
214                 protected override bool HasElementTypeImpl()
215                 {
216                         return typeImpl.HasElementType;
217                 }
218
219                 public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
220                         return typeImpl.InvokeMember (name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
221                 }
222
223                 protected override bool IsArrayImpl()
224                 {
225                         return typeImpl.IsArray;
226                 }
227
228                 protected override bool IsByRefImpl()
229                 {
230                         return typeImpl.IsByRef;
231                 }
232
233                 protected override bool IsCOMObjectImpl()
234                 {
235                         return typeImpl.IsCOMObject;
236                 }
237
238                 public override bool IsDefined( Type attributeType, bool inherit) {
239                         return typeImpl.IsDefined (attributeType, inherit);
240                 }
241
242                 protected override bool IsPointerImpl()
243                 {
244                         return typeImpl.IsPointer;
245                 }
246
247                 protected override bool IsPrimitiveImpl()
248                 {
249                         return typeImpl.IsPrimitive;
250                 }
251
252                 protected override bool IsValueTypeImpl()
253                 {
254                         return typeImpl.IsValueType;
255                 }
256
257                 public override int MetadataToken {
258                         get {
259                                 return typeImpl.MetadataToken;
260                         }
261                 }
262
263         }
264 }