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;
28 private bool has_ctor_constraint;
31 public void SetBaseTypeConstraint (Type base_type_constraint)
33 this.base_type = base_type_constraint;
36 public void SetInterfaceConstraints (Type[] iface_constraints)
38 this.iface_constraints = iface_constraints;
41 public void Mono_SetConstructorConstraint ()
43 has_ctor_constraint = true;
46 internal GenericTypeParameterBuilder (TypeBuilder tbuilder,
47 MethodBuilder mbuilder,
48 string name, int index)
50 this.tbuilder = tbuilder;
51 this.mbuilder = mbuilder;
58 [MethodImplAttribute(MethodImplOptions.InternalCall)]
59 private extern void initialize ();
61 public override bool IsSubclassOf (Type c)
66 return BaseType == c || BaseType.IsSubclassOf (c);
69 protected override TypeAttributes GetAttributeFlagsImpl ()
71 return TypeAttributes.Class;
74 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
76 CallingConventions callConvention,
78 ParameterModifier[] modifiers)
80 throw not_supported ();
83 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
85 throw not_supported ();
88 public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
90 throw not_supported ();
93 public override EventInfo[] GetEvents (BindingFlags bindingAttr)
95 throw not_supported ();
98 public override FieldInfo GetField (string name, BindingFlags bindingAttr)
100 throw not_supported ();
103 public override FieldInfo[] GetFields (BindingFlags bindingAttr)
105 throw not_supported ();
108 public override Type GetInterface (string name, bool ignoreCase)
110 throw not_supported ();
113 public override Type[] GetInterfaces ()
115 throw not_supported ();
118 public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
120 throw not_supported ();
123 public override MethodInfo [] GetMethods (BindingFlags bindingAttr)
125 throw not_supported ();
128 protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
130 CallingConventions callConvention,
131 Type[] types, ParameterModifier[] modifiers)
133 throw not_supported ();
136 public override Type GetNestedType (string name, BindingFlags bindingAttr)
138 throw not_supported ();
141 public override Type[] GetNestedTypes (BindingFlags bindingAttr)
143 throw not_supported ();
146 public override PropertyInfo [] GetProperties (BindingFlags bindingAttr)
148 throw not_supported ();
151 protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr,
152 Binder binder, Type returnType,
154 ParameterModifier[] modifiers)
156 throw not_supported ();
159 protected override bool HasElementTypeImpl ()
164 protected override bool IsArrayImpl ()
169 protected override bool IsByRefImpl ()
174 protected override bool IsCOMObjectImpl ()
179 protected override bool IsPointerImpl ()
184 protected override bool IsPrimitiveImpl ()
189 protected override bool IsValueTypeImpl ()
193 // return base_type != null ? base_type.IsValueType : false;
196 public override object InvokeMember (string name, BindingFlags invokeAttr,
197 Binder binder, object target, object[] args,
198 ParameterModifier[] modifiers,
199 CultureInfo culture, string[] namedParameters)
201 throw not_supported ();
204 public override Type GetElementType ()
206 throw not_supported ();
209 public override Type UnderlyingSystemType {
215 public override Assembly Assembly {
216 get { return tbuilder.Assembly; }
219 public override string AssemblyQualifiedName {
223 public override Type BaseType {
224 get { return base_type; }
227 public override string FullName {
231 public override Guid GUID {
232 get { return Guid.Empty; }
235 public override bool IsDefined (Type attributeType, bool inherit)
237 throw not_supported ();
240 public override object[] GetCustomAttributes (bool inherit)
242 throw not_supported ();
245 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
247 throw not_supported ();
250 public override MemberTypes MemberType {
251 get { return MemberTypes.TypeInfo; }
254 public override string Name {
258 public override string Namespace {
262 public override Module Module {
263 get { return tbuilder.Module; }
266 public override Type DeclaringType {
267 get { return mbuilder != null ? null : tbuilder; }
270 public override Type ReflectedType {
272 return DeclaringType;
276 public override RuntimeTypeHandle TypeHandle {
277 get { throw not_supported (); }
280 public override int GetArrayRank ()
282 throw not_supported ();
285 public override Type GetGenericTypeDefinition ()
287 throw not_supported ();
290 public override bool HasGenericArguments {
291 get { return false; }
294 public override bool ContainsGenericParameters {
295 get { return false; }
298 public override bool IsGenericParameter {
302 public override int GenericParameterPosition {
303 get { return index; }
306 public override MethodInfo DeclaringMethod {
307 get { return mbuilder; }
310 private Exception not_supported ()
312 return new NotSupportedException ();
315 public override string ToString ()