ConstructorBuilder

ConstructorBuilder

System.Reflection.Emit (mscorlib.dll)sealed class

This class represents a dynamically created constructor method. Create a constructor and add it to a type using either the TypeBuilder.DefineConstructor( ) method or the TypeBuilder.DefineDefaultConstructor( ) method. The default constructor accepts no parameters, and just calls the constructor of the parent class. You cannot use the ILGenerator class with a default constructor, because its code is provided by the runtime. Generally, a default constructor does not need to be created, as the CLR provides it for you.

If you create a custom constructor with TypeBuilder.DefineConstructor( ), you can specify the constructor's parameters as an array of System.Type objects. Alternatively, you can use the DefineParameter( ) method to create a ParameterBuilder. You can also add MSIL code to the constructor using the GetILGenerator( ) method.

public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo {
// Public Instance Properties
   public override MethodAttributes Attributes{get; } 
// overrides System.Reflection.MethodBase
   public override Type DeclaringType{get; }          
// overrides System.Reflection.MemberInfo
   public bool InitLocals{set; get; }
   public override RuntimeMethodHandle MethodHandle{get; }    
// overrides System.Reflection.MethodBase
   public override string Name{get; }    
// overrides System.Reflection.MemberInfo
   public override Type ReflectedType{get; }          
// overrides System.Reflection.MemberInfo
   public Type ReturnType{get; }
   public string Signature{get; }
// Public Instance Methods
   public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction action,
       System.Security.PermissionSet pset);
   public ParameterBuilder DefineParameter(int iSequence,
       System.Reflection.ParameterAttributes attributes, string strParamName);
  public override object[ ] GetCustomAttributes(bool inherit)
// overrides System.Reflection.MemberInfo
  public override object[ ] GetCustomAttributes(Type attributeType, bool inherit)
// overrides System.Reflection.MemberInfo
   public ILGenerator GetILGenerator( );
  public override MethodImplAttributes GetMethodImplementationFlags( )
// overrides System.Reflection.MethodBase
   public Module GetModule( );
   public override ParameterInfo[ ] GetParameters( )
// overrides System.Reflection.MethodBase
   public MethodToken GetToken( );
   public override object Invoke(System.Reflection.BindingFlags invokeAttr, 
       System.Reflection.Binder binder, object[ ] parameters, 
       System.Globalization.CultureInfo culture);  
// overrides System.Reflection.ConstructorInfo
   public override object Invoke(object obj, System.Reflection.BindingFlags invokeAttr, 
       System.Reflection.Binder binder, object[ ] parameters, 
       System.Globalization.CultureInfo culture)
// overrides System.Reflection.MethodBase
   public override bool IsDefined(Type attributeType, bool inherit)
// overrides System.Reflection.MemberInfo
   public void SetCustomAttribute(System.Reflection.ConstructorInfo con, 
        byte[ ] binaryAttribute);
   public void SetCustomAttribute(CustomAttributeBuilder customBuilder);
   public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
   public void SetSymCustomAttribute(string name, byte[ ] data);
   public override string ToString( );    
// overrides object
}

Hierarchy

System.Object System.Reflection.MemberInfo(System.Reflection.ICustomAttributeProvider) System.Reflection.MethodBase System.Reflection.ConstructorInfo ConstructorBuilder

Returned By

TypeBuilder.{DefineConstructor( ), DefineDefaultConstructor( ), DefineTypeInitializer( )}



    Part II: Programming with the .NET Framework
    Part IV: API Quick Reference
    Chapter 26. System
     
    ASPTreeView.com
     
    Evaluation has ИНФёБј·expired.
    Info...