This class represents a dynamically
created type in a dynamic
module (ModuleBuilder object). Generally, a type
is either a class or an interface. To create a
TypeBuilder, use the overloaded
ModuleBuilder.DefineType( ) method. Depending on
which overload you use, you can specify different information
including the type name, superclass, and implemented interfaces. You
can also use the System.Reflection.TypeAttributes
enumeration to specify other options, such as making a class sealed,
abstract, or public, or defining it as an interface. Once the type is
created, you can add members such as constructors, events, fields,
properties, methods, and other nested types, using the corresponding
Define method.
Before using a type you created, you must use the
CreateType( ) method to get a
Type object. After that, you can instantiate the
Type with the
System.Activator.CreateInstance( ) method, and
invoke members of the type with the
System.Type.InvokeMember( ) method. After creating
a type, you can no longer use TypeBuilder methods
that would change the type, such as a Define
method.
public sealed class TypeBuilder : Type {
// Public Static Fields
public const int UnspecifiedTypeSize;
// =0
// Public Instance Properties
public override Assembly Assembly{get; }
// overrides Type
public override string AssemblyQualifiedName{get; }
// overrides Type
public override Type BaseType{get; }
// overrides Type
public override Type DeclaringType{get; }
// overrides Type
public override string FullName{get; }
// overrides Type
public override Guid GUID{get; }
// overrides Type
public override Module Module{get; }
// overrides Type
public override string Name{get; }
// overrides System.Reflection.MemberInfo
public override string Namespace{get; }
// overrides Type
public PackingSize PackingSize{get; }
public override Type ReflectedType{get; }
// overrides Type
public int Size{get; }
public override RuntimeTypeHandle TypeHandle{get; }
// overrides Type
public TypeToken TypeToken{get; }
public override Type UnderlyingSystemType{get; }
// overrides Type
// Public Instance Methods
public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction action,
System.Security.PermissionSet pset);
public void AddInterfaceImplementation(Type interfaceType);
public Type CreateType( );
public ConstructorBuilder DefineConstructor(System.Reflection.MethodAttributes attributes,
System.Reflection.CallingConventions callingConvention,Type[ ] parameterTypes);
public ConstructorBuilder DefineDefaultConstructor(System.Reflection.MethodAttributes attributes);
public EventBuilder DefineEvent(string name, System.Reflection.EventAttributes attributes,
Type eventtype);
public FieldBuilder DefineField(string fieldName, Type type,
System.Reflection.FieldAttributes attributes);
public FieldBuilder DefineInitializedData(string name, byte[ ] data,
System.Reflection.FieldAttributes attributes);
public MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes,
System.Reflection.CallingConventions callingConvention,Type returnType, Type[ ] parameterTypes);
public MethodBuilder DefineMethod(string name, System.Reflection.MethodAttributes attributes,
Type returnType, Type[ ] parameterTypes);
public void DefineMethodOverride(System.Reflection.MethodInfo methodInfoBody,
System.Reflection.MethodInfo methodInfoDeclaration);
public TypeBuilder DefineNestedType(string name);
public TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr);
public TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr,
Type parent);
public TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr,
Type parent, int typeSize);
public TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr,
Type parent,PackingSize packSize);
public TypeBuilder DefineNestedType(string name, System.Reflection.TypeAttributes attr,
Type parent, Type[ ] interfaces);
public MethodBuilder DefinePInvokeMethod(string name, string dllName,
System.Reflection.MethodAttributes attributes,
System.Reflection.CallingConventions callingConvention,
Type returnType, Type[ ] parameterTypes,
System.Runtime.InteropServices.CallingConvention nativeCallConv,
System.Runtime.InteropServices.CharSet nativeCharSet);
public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName,
System.Reflection.MethodAttributes attributes,
System.Reflection.CallingConventions callingConvention,
Type returnType, Type[ ] parameterTypes,
System.Runtime.InteropServices.CallingConvention nativeCallConv,
System.Runtime.InteropServices.CharSet nativeCharSet);
public PropertyBuilder DefineProperty(string name,
System.Reflection.PropertyAttributes attributes,
Type returnType, Type[ ] parameterTypes);
public ConstructorBuilder DefineTypeInitializer( );
public FieldBuilder DefineUninitializedData(string name, int size,
System.Reflection.FieldAttributes attributes);
public override ConstructorInfo[ ] GetConstructors(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override object[ ] GetCustomAttributes( bool inherit)
// overrides System.Reflection.MemberInfo
public override object[ ] GetCustomAttributes(Type attributeType,bool inherit)
// overrides System.Reflection.MemberInfo
public override Type GetElementType( );
// overrides Type
public override EventInfo GetEvent(string name, System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override EventInfo[ ] GetEvents( );
// overrides Type
public override EventInfo[ ] GetEvents(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override FieldInfo GetField(string name, System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override FieldInfo[ ] GetFields(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override Type GetInterface(string name, bool ignoreCase)
// overrides Type
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
// overrides Type
public override Type[ ] GetInterfaces( );
// overrides Type
public override MemberInfo[ ] GetMember(string name, System.Reflection.MemberTypes type,
System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override MemberInfo[ ] GetMembers(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override MethodInfo[ ] GetMethods(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override Type GetNestedType(string name, System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override Type[ ] GetNestedTypes(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override PropertyInfo[ ] GetProperties(System.Reflection.BindingFlags bindingAttr)
// overrides Type
public override object InvokeMember(string name, System.Reflection.BindingFlags invokeAttr,
System.Reflection.Binder binder, object target, object[ ] args,
System.Reflection.ParameterModifier[ ] modifiers,
System.Globalization.CultureInfo culture, string[ ] namedParameters)
// overrides Type
public override bool IsAssignableFrom(Type c);
// overrides Type
public override bool IsDefined(Type attributeType, bool inherit)
// overrides System.Reflection.MemberInfo
public override bool IsSubclassOf(Type c);
// overrides Type
public void SetCustomAttribute(System.Reflection.ConstructorInfo con,
byte[ ] binaryAttribute);
public void SetCustomAttribute(CustomAttributeBuilder customBuilder);
public void SetParent(Type parent);
public override string ToString( );
// overrides Type
// Protected Instance Methods
protected override TypeAttributes GetAttributeFlagsImpl( );
// overrides Type
protected override ConstructorInfo GetConstructorImpl(System.Reflection.BindingFlags bindingAttr,
System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention,
Type[ ] types,
System.Reflection.ParameterModifier[ ] modifiers)
// overrides Type
protected override MethodInfo GetMethodImpl(string name, System.Reflection.BindingFlags bindingAttr,
System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention,
Type[ ] types,
System.Reflection.ParameterModifier[ ] modifiers)
// overrides Type
protected override PropertyInfo GetPropertyImpl(string name,
System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder,
Type returnType, Type[ ] types,
System.Reflection.ParameterModifier[ ] modifiers)
// overrides Type
protected override bool HasElementTypeImpl( );
// overrides Type
protected override bool IsArrayImpl( );
// overrides Type
protected override bool IsByRefImpl( );
// overrides Type
protected override bool IsCOMObjectImpl( );
// overrides Type
protected override bool IsPointerImpl( );
// overrides Type
protected override bool IsPrimitiveImpl( );
// overrides Type
}