1 // System.Reflection/TypeDelegator.cs
3 // Paolo Molaro (lupus@ximian.com)
5 // (C) 2002 Ximian, Inc.
8 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
31 using System
.Reflection
;
32 using System
.Globalization
;
33 using System
.Runtime
.InteropServices
;
35 namespace System
.Reflection
{
39 public class TypeDelegator
: Type
{
40 protected Type typeImpl
;
42 protected TypeDelegator () {
45 public TypeDelegator( Type delegatingType
)
47 if (delegatingType
== null)
48 throw new ArgumentNullException ("delegatingType must be non-null");
49 typeImpl
= delegatingType
;
52 public override Assembly Assembly
{
53 get { return typeImpl.Assembly; }
56 public override string AssemblyQualifiedName
{
57 get { return typeImpl.AssemblyQualifiedName; }
60 public override Type BaseType
{
61 get { return typeImpl.BaseType; }
64 public override string FullName
{
65 get { return typeImpl.FullName; }
68 public override Guid GUID
{
69 get { return typeImpl.GUID; }
72 public override Module Module
{
73 get { return typeImpl.Module; }
76 public override string Name
{
77 get { return typeImpl.Name; }
80 public override string Namespace
{
81 get { return typeImpl.Namespace; }
84 public override RuntimeTypeHandle TypeHandle
{
85 get { return typeImpl.TypeHandle; }
88 public override Type UnderlyingSystemType
{
89 get { return typeImpl.UnderlyingSystemType; }
92 protected override TypeAttributes
GetAttributeFlagsImpl ()
94 return typeImpl
.Attributes
;
97 protected override ConstructorInfo
GetConstructorImpl (
98 BindingFlags bindingAttr
, Binder binder
, CallingConventions callConvention
,
99 Type
[] types
, ParameterModifier
[] modifiers
)
101 return typeImpl
.GetConstructor (bindingAttr
, binder
, callConvention
, types
, modifiers
);
105 public override ConstructorInfo
[] GetConstructors( BindingFlags bindingAttr
)
107 return typeImpl
.GetConstructors (bindingAttr
);
110 public override object[] GetCustomAttributes (bool inherit
)
112 return typeImpl
.GetCustomAttributes (inherit
);
115 public override object[] GetCustomAttributes (Type attributeType
, bool inherit
)
117 return typeImpl
.GetCustomAttributes (attributeType
, inherit
);
120 public override Type
GetElementType()
122 return typeImpl
.GetElementType ();
125 public override EventInfo
GetEvent( string name
, BindingFlags bindingAttr
)
127 return typeImpl
.GetEvent (name
, bindingAttr
);
130 public override EventInfo
[] GetEvents()
132 return GetEvents (BindingFlags
.Public
);
135 public override EventInfo
[] GetEvents (BindingFlags bindingAttr
)
137 return typeImpl
.GetEvents (bindingAttr
);
140 public override FieldInfo
GetField (string name
, BindingFlags bindingAttr
)
142 return typeImpl
.GetField (name
, bindingAttr
);
145 public override FieldInfo
[] GetFields( BindingFlags bindingAttr
)
147 return typeImpl
.GetFields (bindingAttr
);
150 public override Type
GetInterface( string name
, bool ignoreCase
)
152 return typeImpl
.GetInterface (name
, ignoreCase
);
156 public override InterfaceMapping
GetInterfaceMap( Type interfaceType
)
158 return typeImpl
.GetInterfaceMap (interfaceType
);
161 public override Type
[] GetInterfaces ()
163 return typeImpl
.GetInterfaces ();
166 public override MemberInfo
[] GetMember( string name
, MemberTypes type
, BindingFlags bindingAttr
)
168 return typeImpl
.GetMember (name
, type
, bindingAttr
);
171 public override MemberInfo
[] GetMembers( BindingFlags bindingAttr
)
173 return typeImpl
.GetMembers (bindingAttr
);
176 protected override MethodInfo
GetMethodImpl( string name
, BindingFlags bindingAttr
, Binder binder
, CallingConventions callConvention
, Type
[] types
, ParameterModifier
[] modifiers
)
178 // Can't call GetMethod since it makes restrictive argument checks
179 return typeImpl
.GetMethodImplInternal (name
, bindingAttr
, binder
, callConvention
, types
, modifiers
);
182 public override MethodInfo
[] GetMethods( BindingFlags bindingAttr
)
184 return typeImpl
.GetMethods (bindingAttr
);
187 public override Type
GetNestedType( string name
, BindingFlags bindingAttr
)
189 return typeImpl
.GetNestedType (name
, bindingAttr
);
192 public override Type
[] GetNestedTypes( BindingFlags bindingAttr
)
194 return typeImpl
.GetNestedTypes (bindingAttr
);
197 public override PropertyInfo
[] GetProperties( BindingFlags bindingAttr
)
199 return typeImpl
.GetProperties (bindingAttr
);
202 protected override PropertyInfo
GetPropertyImpl( string name
, BindingFlags bindingAttr
, Binder binder
, Type returnType
, Type
[] types
, ParameterModifier
[] modifiers
)
204 // Can't call GetProperty since it makes restrictive argument checks
205 return typeImpl
.GetPropertyImplInternal (name
, bindingAttr
, binder
, returnType
, types
, modifiers
);
208 protected override bool HasElementTypeImpl()
210 return typeImpl
.HasElementType
;
213 public override object InvokeMember( string name
, BindingFlags invokeAttr
, Binder binder
, object target
, object[] args
, ParameterModifier
[] modifiers
, CultureInfo culture
, string[] namedParameters
) {
214 return typeImpl
.InvokeMember (name
, invokeAttr
, binder
, target
, args
, modifiers
, culture
, namedParameters
);
217 protected override bool IsArrayImpl()
219 return typeImpl
.IsArray
;
222 protected override bool IsByRefImpl()
224 return typeImpl
.IsByRef
;
227 protected override bool IsCOMObjectImpl()
229 return typeImpl
.IsCOMObject
;
232 public override bool IsDefined( Type attributeType
, bool inherit
) {
233 return typeImpl
.IsDefined (attributeType
, inherit
);
236 protected override bool IsPointerImpl()
238 return typeImpl
.IsPointer
;
241 protected override bool IsPrimitiveImpl()
243 return typeImpl
.IsPrimitive
;
246 protected override bool IsValueTypeImpl()
248 return typeImpl
.IsValueType
;
251 public override int MetadataToken
{
253 return typeImpl
.MetadataToken
;