2 // System.Reflection.Emit.GenericTypeParameterBuilder
4 // Martin Baulig (martin@ximian.com)
6 // (C) 2004 Novell, Inc.
9 using System.Reflection;
10 using System.Reflection.Emit;
11 using System.Collections;
12 using System.Runtime.CompilerServices;
13 using System.Globalization;
14 using System.Runtime.Serialization;
17 namespace System.Reflection.Emit
19 public sealed class GenericTypeParameterBuilder : Type
21 #region Sync with reflection.h
22 private TypeBuilder tbuilder;
23 private MethodBuilder mbuilder;
26 private Type base_type;
27 private Type[] iface_constraints;
30 public void SetBaseTypeConstraint (Type base_type_constraint)
32 this.base_type = base_type_constraint;
35 public void SetInterfaceConstraints (Type[] iface_constraints)
37 this.iface_constraints = iface_constraints;
40 internal GenericTypeParameterBuilder (TypeBuilder tbuilder,
41 MethodBuilder mbuilder,
42 string name, int index)
44 this.tbuilder = tbuilder;
45 this.mbuilder = mbuilder;
52 [MethodImplAttribute(MethodImplOptions.InternalCall)]
53 private extern void initialize ();
55 public override bool IsSubclassOf (Type c)
60 return BaseType == c || BaseType.IsSubclassOf (c);
63 protected override TypeAttributes GetAttributeFlagsImpl ()
65 return TypeAttributes.Class;
68 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
70 CallingConventions callConvention,
72 ParameterModifier[] modifiers)
74 throw not_supported ();
77 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
79 throw not_supported ();
82 public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
84 throw not_supported ();
87 public override EventInfo[] GetEvents (BindingFlags bindingAttr)
89 throw not_supported ();
92 public override FieldInfo GetField (string name, BindingFlags bindingAttr)
94 throw not_supported ();
97 public override FieldInfo[] GetFields (BindingFlags bindingAttr)
99 throw not_supported ();
102 public override Type GetInterface (string name, bool ignoreCase)
104 throw not_supported ();
107 public override Type[] GetInterfaces ()
109 throw not_supported ();
112 public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
114 throw not_supported ();
117 public override MethodInfo [] GetMethods (BindingFlags bindingAttr)
119 throw not_supported ();
122 protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
124 CallingConventions callConvention,
125 Type[] types, ParameterModifier[] modifiers)
127 throw not_supported ();
130 public override Type GetNestedType (string name, BindingFlags bindingAttr)
132 throw not_supported ();
135 public override Type[] GetNestedTypes (BindingFlags bindingAttr)
137 throw not_supported ();
140 public override PropertyInfo [] GetProperties (BindingFlags bindingAttr)
142 throw not_supported ();
145 protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr,
146 Binder binder, Type returnType,
148 ParameterModifier[] modifiers)
150 throw not_supported ();
153 protected override bool HasElementTypeImpl ()
158 protected override bool IsArrayImpl ()
163 protected override bool IsByRefImpl ()
168 protected override bool IsCOMObjectImpl ()
173 protected override bool IsPointerImpl ()
178 protected override bool IsPrimitiveImpl ()
183 protected override bool IsValueTypeImpl ()
187 return base_type != null ? base_type.IsValueType : false;
190 public override object InvokeMember (string name, BindingFlags invokeAttr,
191 Binder binder, object target, object[] args,
192 ParameterModifier[] modifiers,
193 CultureInfo culture, string[] namedParameters)
195 throw not_supported ();
198 public override Type GetElementType ()
200 throw not_supported ();
203 public override Type UnderlyingSystemType {
209 public override Assembly Assembly {
210 get { return tbuilder.Assembly; }
213 public override string AssemblyQualifiedName {
217 public override Type BaseType {
218 get { return base_type; }
221 public override string FullName {
225 public override Guid GUID {
226 get { return Guid.Empty; }
229 public override bool IsDefined (Type attributeType, bool inherit)
231 throw not_supported ();
234 public override object[] GetCustomAttributes (bool inherit)
236 throw not_supported ();
239 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
241 throw not_supported ();
244 public override MemberTypes MemberType {
245 get { return MemberTypes.TypeInfo; }
248 public override string Name {
252 public override string Namespace {
256 public override Module Module {
257 get { return tbuilder.Module; }
260 public override Type DeclaringType {
261 get { return mbuilder != null ? null : tbuilder; }
264 public override Type ReflectedType {
266 return DeclaringType;
270 public override RuntimeTypeHandle TypeHandle {
271 get { throw not_supported (); }
274 public override int GetArrayRank ()
276 throw not_supported ();
279 public override Type GetGenericTypeDefinition ()
281 throw not_supported ();
284 public override bool HasGenericArguments {
285 get { return false; }
288 public override bool ContainsGenericParameters {
289 get { return false; }
292 public override bool IsGenericParameter {
296 public override int GenericParameterPosition {
297 get { return index; }
300 public override MethodInfo DeclaringMethod {
301 get { return mbuilder; }
304 private Exception not_supported ()
306 return new NotSupportedException ();
309 public override string ToString ()