ConstructorBuilder クラス

定義

動的クラスのコンストラクターを定義し、表します。

public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo
public ref class ConstructorBuilder abstract : System::Reflection::ConstructorInfo
public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo, System::Runtime::InteropServices::_ConstructorBuilder
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo
public abstract class ConstructorBuilder : System.Reflection.ConstructorInfo
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
type ConstructorBuilder = class
    inherit ConstructorInfo
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type ConstructorBuilder = class
    inherit ConstructorInfo
    interface _ConstructorBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ConstructorBuilder = class
    inherit ConstructorInfo
    interface _ConstructorBuilder
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
Public MustInherit Class ConstructorBuilder
Inherits ConstructorInfo
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
Implements _ConstructorBuilder
継承
属性
実装

次のコード サンプルは、 のコンテキストでの使用方法を ConstructorBuilder示しています。

using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
Type^ DynamicPointTypeGen()
{
   Type^ pointType = nullptr;
   array<Type^>^temp0 = {int::typeid,int::typeid,int::typeid};
   array<Type^>^ctorParams = temp0;
   AppDomain^ myDomain = Thread::GetDomain();
   AssemblyName^ myAsmName = gcnew AssemblyName;
   myAsmName->Name = "MyDynamicAssembly";
   AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave );
   ModuleBuilder^ pointModule = myAsmBuilder->DefineDynamicModule( "PointModule", "Point.dll" );
   TypeBuilder^ pointTypeBld = pointModule->DefineType( "Point", TypeAttributes::Public );
   FieldBuilder^ xField = pointTypeBld->DefineField( "x", int::typeid, FieldAttributes::Public );
   FieldBuilder^ yField = pointTypeBld->DefineField( "y", int::typeid, FieldAttributes::Public );
   FieldBuilder^ zField = pointTypeBld->DefineField( "z", int::typeid, FieldAttributes::Public );
   Type^ objType = Type::GetType( "System.Object" );
   ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array<Type^>(0) );
   ConstructorBuilder^ pointCtor = pointTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams );
   ILGenerator^ ctorIL = pointCtor->GetILGenerator();
   
   // NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
   // hold the actual passed parameters. ldarg.0 is used by instance methods
   // to hold a reference to the current calling bject instance. Static methods
   // do not use arg.0, since they are not instantiated and hence no reference
   // is needed to distinguish them.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   
   // Here, we wish to create an instance of System::Object by invoking its
   // constructor, as specified above.
   ctorIL->Emit( OpCodes::Call, objCtor );
   
   // Now, we'll load the current instance in arg 0, along
   // with the value of parameter "x" stored in arg 1, into stfld.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_1 );
   ctorIL->Emit( OpCodes::Stfld, xField );
   
   // Now, we store arg 2 "y" in the current instance with stfld.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_2 );
   ctorIL->Emit( OpCodes::Stfld, yField );
   
   // Last of all, arg 3 "z" gets stored in the current instance.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_3 );
   ctorIL->Emit( OpCodes::Stfld, zField );
   
   // Our work complete, we return.
   ctorIL->Emit( OpCodes::Ret );
   
   // Now, let's create three very simple methods so we can see our fields.
   array<String^>^temp1 = {"GetX","GetY","GetZ"};
   array<String^>^mthdNames = temp1;
   System::Collections::IEnumerator^ myEnum = mthdNames->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ mthdName = safe_cast<String^>(myEnum->Current);
      MethodBuilder^ getFieldMthd = pointTypeBld->DefineMethod( mthdName, MethodAttributes::Public, int::typeid, nullptr );
      ILGenerator^ mthdIL = getFieldMthd->GetILGenerator();
      mthdIL->Emit( OpCodes::Ldarg_0 );
      if ( mthdName->Equals( "GetX" ) )
            mthdIL->Emit( OpCodes::Ldfld, xField );
      else
      if ( mthdName->Equals( "GetY" ) )
            mthdIL->Emit( OpCodes::Ldfld, yField );
      else
      if ( mthdName->Equals( "GetZ" ) )
            mthdIL->Emit( OpCodes::Ldfld, zField );



      mthdIL->Emit( OpCodes::Ret );
   }

   pointType = pointTypeBld->CreateType();
   
   // Let's save it, just for posterity.
   myAsmBuilder->Save( "Point.dll" );
   return pointType;
}

int main()
{
   Type^ myDynamicType = nullptr;
   Object^ aPoint = nullptr;
   array<Type^>^temp2 = {int::typeid,int::typeid,int::typeid};
   array<Type^>^aPtypes = temp2;
   array<Object^>^temp3 = {4,5,6};
   array<Object^>^aPargs = temp3;
   
   // Call the  method to build our dynamic class.
   myDynamicType = DynamicPointTypeGen();
   Console::WriteLine( "Some information about my new Type '{0}':", myDynamicType->FullName );
   Console::WriteLine( "Assembly: '{0}'", myDynamicType->Assembly );
   Console::WriteLine( "Attributes: '{0}'", myDynamicType->Attributes );
   Console::WriteLine( "Module: '{0}'", myDynamicType->Module );
   Console::WriteLine( "Members: " );
   System::Collections::IEnumerator^ myEnum = myDynamicType->GetMembers()->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      MemberInfo^ member = safe_cast<MemberInfo^>(myEnum->Current);
      Console::WriteLine( "-- {0} {1};", member->MemberType, member->Name );
   }

   Console::WriteLine( "---" );
   
   // Let's take a look at the constructor we created.
   ConstructorInfo^ myDTctor = myDynamicType->GetConstructor( aPtypes );
   Console::WriteLine( "Constructor: {0};", myDTctor );
   Console::WriteLine( "---" );
   
   // Now, we get to use our dynamically-created class by invoking the constructor.
   aPoint = myDTctor->Invoke( aPargs );
   Console::WriteLine( "aPoint is type {0}.", aPoint->GetType() );
   
   // Finally, let's reflect on the instance of our new type - aPoint - and
   // make sure everything proceeded according to plan.
   Console::WriteLine( "aPoint.x = {0}", myDynamicType->InvokeMember( "GetX", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
   Console::WriteLine( "aPoint.y = {0}", myDynamicType->InvokeMember( "GetY", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
   Console::WriteLine( "aPoint.z = {0}", myDynamicType->InvokeMember( "GetZ", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
   
   // +++ OUTPUT +++
   // Some information about my new Type 'Point':
   // Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
   // Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
   // Module: 'PointModule'
   // Members:
   // -- Field x;
   // -- Field y;
   // -- Field z;
   // -- Method GetHashCode;
   // -- Method Equals;
   // -- Method ToString;
   // -- Method GetType;
   // -- Constructor .ctor;
   // ---
   // Constructor: Void .ctor(Int32, Int32, Int32);
   // ---
   // aPoint is type Point.
   // aPoint.x = 4
   // aPoint.y = 5
   // aPoint.z = 6
}

using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

class TestCtorBuilder {

    public static Type DynamicPointTypeGen() {
    
       Type pointType = null;
       Type[] ctorParams = new Type[] {typeof(int),
                        typeof(int),
                        typeof(int)};
    
       AppDomain myDomain = Thread.GetDomain();
       AssemblyName myAsmName = new AssemblyName();
       myAsmName.Name = "MyDynamicAssembly";
    
       AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
                      myAsmName,
                      AssemblyBuilderAccess.RunAndSave);

       ModuleBuilder pointModule = myAsmBuilder.DefineDynamicModule("PointModule",
                                    "Point.dll");

       TypeBuilder pointTypeBld = pointModule.DefineType("Point",
                                      TypeAttributes.Public);

       FieldBuilder xField = pointTypeBld.DefineField("x", typeof(int),
                                                          FieldAttributes.Public);
       FieldBuilder yField = pointTypeBld.DefineField("y", typeof(int),
                                                          FieldAttributes.Public);
       FieldBuilder zField = pointTypeBld.DefineField("z", typeof(int),
                                                          FieldAttributes.Public);

           Type objType = Type.GetType("System.Object");
           ConstructorInfo objCtor = objType.GetConstructor(new Type[0]);

       ConstructorBuilder pointCtor = pointTypeBld.DefineConstructor(
                      MethodAttributes.Public,
                      CallingConventions.Standard,
                      ctorParams);
       ILGenerator ctorIL = pointCtor.GetILGenerator();

       // NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
       // hold the actual passed parameters. ldarg.0 is used by instance methods
       // to hold a reference to the current calling object instance. Static methods
       // do not use arg.0, since they are not instantiated and hence no reference
       // is needed to distinguish them.

           ctorIL.Emit(OpCodes.Ldarg_0);

       // Here, we wish to create an instance of System.Object by invoking its
       // constructor, as specified above.

           ctorIL.Emit(OpCodes.Call, objCtor);

       // Now, we'll load the current instance ref in arg 0, along
       // with the value of parameter "x" stored in arg 1, into stfld.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_1);
           ctorIL.Emit(OpCodes.Stfld, xField);

       // Now, we store arg 2 "y" in the current instance with stfld.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_2);
           ctorIL.Emit(OpCodes.Stfld, yField);

       // Last of all, arg 3 "z" gets stored in the current instance.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_3);
           ctorIL.Emit(OpCodes.Stfld, zField);

           // Our work complete, we return.

       ctorIL.Emit(OpCodes.Ret);

       // Now, let's create three very simple methods so we can see our fields.

       string[] mthdNames = new string[] {"GetX", "GetY", "GetZ"};

           foreach (string mthdName in mthdNames) {
              MethodBuilder getFieldMthd = pointTypeBld.DefineMethod(
                           mthdName,
                           MethodAttributes.Public,
                                           typeof(int),
                                           null);
          ILGenerator mthdIL = getFieldMthd.GetILGenerator();
    
          mthdIL.Emit(OpCodes.Ldarg_0);
          switch (mthdName) {
             case "GetX": mthdIL.Emit(OpCodes.Ldfld, xField);
                  break;
             case "GetY": mthdIL.Emit(OpCodes.Ldfld, yField);
                  break;
             case "GetZ": mthdIL.Emit(OpCodes.Ldfld, zField);
                  break;
          }
          mthdIL.Emit(OpCodes.Ret);
           }
       // Finally, we create the type.

       pointType = pointTypeBld.CreateType();

       // Let's save it, just for posterity.
    
       myAsmBuilder.Save("Point.dll");
    
       return pointType;
    }

    public static void Main() {
    
       Type myDynamicType = null;
           object aPoint = null;
       Type[] aPtypes = new Type[] {typeof(int), typeof(int), typeof(int)};
           object[] aPargs = new object[] {4, 5, 6};
    
       // Call the  method to build our dynamic class.

       myDynamicType = DynamicPointTypeGen();

       Console.WriteLine("Some information about my new Type '{0}':",
                  myDynamicType.FullName);
       Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly);
       Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes);
       Console.WriteLine("Module: '{0}'", myDynamicType.Module);
       Console.WriteLine("Members: ");
       foreach (MemberInfo member in myDynamicType.GetMembers()) {
        Console.WriteLine("-- {0} {1};", member.MemberType, member.Name);
       }

           Console.WriteLine("---");

       // Let's take a look at the constructor we created.

       ConstructorInfo myDTctor = myDynamicType.GetConstructor(aPtypes);
           Console.WriteLine("Constructor: {0};", myDTctor.ToString());

           Console.WriteLine("---");
    
           // Now, we get to use our dynamically-created class by invoking the constructor.

       aPoint = myDTctor.Invoke(aPargs);
           Console.WriteLine("aPoint is type {0}.", aPoint.GetType());

       // Finally, let's reflect on the instance of our new type - aPoint - and
       // make sure everything proceeded according to plan.

       Console.WriteLine("aPoint.x = {0}",
                 myDynamicType.InvokeMember("GetX",
                                BindingFlags.InvokeMethod,
                            null,
                            aPoint,
                            new object[0]));
       Console.WriteLine("aPoint.y = {0}",
                 myDynamicType.InvokeMember("GetY",
                                BindingFlags.InvokeMethod,
                            null,
                            aPoint,
                            new object[0]));
       Console.WriteLine("aPoint.z = {0}",
                 myDynamicType.InvokeMember("GetZ",
                                BindingFlags.InvokeMethod,
                            null,
                            aPoint,
                            new object[0]));

       // +++ OUTPUT +++
       // Some information about my new Type 'Point':
       // Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
       // Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
       // Module: 'PointModule'
       // Members:
       // -- Field x;
       // -- Field y;
       // -- Field z;
           // -- Method GetHashCode;
           // -- Method Equals;
           // -- Method ToString;
           // -- Method GetType;
           // -- Constructor .ctor;
       // ---
       // Constructor: Void .ctor(Int32, Int32, Int32);
       // ---
       // aPoint is type Point.
       // aPoint.x = 4
       // aPoint.y = 5
       // aPoint.z = 6
    }
}

Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

 _

Class TestCtorBuilder
   
   
   Public Shared Function DynamicPointTypeGen() As Type
      
      Dim pointType As Type = Nothing
      Dim ctorParams() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      
      Dim myDomain As AppDomain = Thread.GetDomain()
      Dim myAsmName As New AssemblyName()
      myAsmName.Name = "MyDynamicAssembly"
      
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.RunAndSave)
      
      Dim pointModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule("PointModule", "Point.dll")
      
      Dim pointTypeBld As TypeBuilder = pointModule.DefineType("Point", TypeAttributes.Public)
      
      Dim xField As FieldBuilder = pointTypeBld.DefineField("x", GetType(Integer), FieldAttributes.Public)
      Dim yField As FieldBuilder = pointTypeBld.DefineField("y", GetType(Integer), FieldAttributes.Public)
      Dim zField As FieldBuilder = pointTypeBld.DefineField("z", GetType(Integer), FieldAttributes.Public)
      
      Dim objType As Type = Type.GetType("System.Object")
      Dim objCtor As ConstructorInfo = objType.GetConstructor(New Type() {})
      
      Dim pointCtor As ConstructorBuilder = pointTypeBld.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ctorParams)
      Dim ctorIL As ILGenerator = pointCtor.GetILGenerator()
      
      ' NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
      ' hold the actual passed parameters. ldarg.0 is used by instance methods
      ' to hold a reference to the current calling object instance. Static methods
      ' do not use arg.0, since they are not instantiated and hence no reference
      ' is needed to distinguish them. 
      ctorIL.Emit(OpCodes.Ldarg_0)
      
      ' Here, we wish to create an instance of System.Object by invoking its
      ' constructor, as specified above.
      ctorIL.Emit(OpCodes.Call, objCtor)
      
      ' Now, we'll load the current instance ref in arg 0, along
      ' with the value of parameter "x" stored in arg 1, into stfld.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_1)
      ctorIL.Emit(OpCodes.Stfld, xField)
      
      ' Now, we store arg 2 "y" in the current instance with stfld.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_2)
      ctorIL.Emit(OpCodes.Stfld, yField)
      
      ' Last of all, arg 3 "z" gets stored in the current instance.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_3)
      ctorIL.Emit(OpCodes.Stfld, zField)
      
      ' Our work complete, we return.
      ctorIL.Emit(OpCodes.Ret)
      
      ' Now, let's create three very simple methods so we can see our fields.
      Dim mthdNames() As String = {"GetX", "GetY", "GetZ"}
      
      Dim mthdName As String
      For Each mthdName In  mthdNames
         Dim getFieldMthd As MethodBuilder = pointTypeBld.DefineMethod(mthdName, MethodAttributes.Public, GetType(Integer), Nothing)
         Dim mthdIL As ILGenerator = getFieldMthd.GetILGenerator()
         
         mthdIL.Emit(OpCodes.Ldarg_0)
         Select Case mthdName
            Case "GetX"
               mthdIL.Emit(OpCodes.Ldfld, xField)
            Case "GetY"
               mthdIL.Emit(OpCodes.Ldfld, yField)
            Case "GetZ"
               mthdIL.Emit(OpCodes.Ldfld, zField)
         End Select
         
         mthdIL.Emit(OpCodes.Ret)
      Next mthdName 
      ' Finally, we create the type.
      pointType = pointTypeBld.CreateType()
      
      ' Let's save it, just for posterity.
      myAsmBuilder.Save("Point.dll")
      
      Return pointType
   End Function 'DynamicPointTypeGen
    
   
   Public Shared Sub Main()
      
      Dim myDynamicType As Type = Nothing
      Dim aPoint As Object = Nothing
      Dim aPtypes() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      Dim aPargs() As Object = {4, 5, 6}
      
      ' Call the  method to build our dynamic class.
      myDynamicType = DynamicPointTypeGen()
      
      Console.WriteLine("Some information about my new Type '{0}':", myDynamicType.FullName)
      Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly)
      Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes)
      Console.WriteLine("Module: '{0}'", myDynamicType.Module)
      Console.WriteLine("Members: ")
      Dim member As MemberInfo
      For Each member In  myDynamicType.GetMembers()
         Console.WriteLine("-- {0} {1};", member.MemberType, member.Name)
      Next member
      
      Console.WriteLine("---")
      
      ' Let's take a look at the constructor we created.
      Dim myDTctor As ConstructorInfo = myDynamicType.GetConstructor(aPtypes)
      Console.WriteLine("Constructor: {0};", myDTctor.ToString())
      
      Console.WriteLine("---")
      
      ' Now, we get to use our dynamically-created class by invoking the constructor. 
      aPoint = myDTctor.Invoke(aPargs)
      Console.WriteLine("aPoint is type {0}.", aPoint.GetType())
      
      
      ' Finally, let's reflect on the instance of our new type - aPoint - and
      ' make sure everything proceeded according to plan.
      Console.WriteLine("aPoint.x = {0}", myDynamicType.InvokeMember("GetX", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
      Console.WriteLine("aPoint.y = {0}", myDynamicType.InvokeMember("GetY", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
      Console.WriteLine("aPoint.z = {0}", myDynamicType.InvokeMember("GetZ", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
   End Sub
End Class



' +++ OUTPUT +++
' Some information about my new Type 'Point':
' Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
' Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
' Module: 'PointModule'
' Members: 
' -- Field x;
' -- Field y;
' -- Field z;
' -- Method GetHashCode;
' -- Method Equals;
' -- Method ToString;
' -- Method GetType;
' -- Constructor .ctor;
' ---
' Constructor: Void .ctor(Int32, Int32, Int32);
' ---
' aPoint is type Point.
' aPoint.x = 4
' aPoint.y = 5
' aPoint.z = 6

注釈

ConstructorBuilder は、名前、属性、シグネチャ、コンストラクター本体など、Microsoft 中間言語 (MSIL) でコンストラクターを完全に記述するために使用されます。 実行時にクラスを作成するために、 TypeBuilder クラスと組み合わせて使用されます。 を呼び出 DefineConstructor して の ConstructorBuilderインスタンスを取得します。

動的型のコンストラクターを定義しない場合は、パラメーターなしのコンストラクターが自動的に提供され、基底クラスのパラメーターなしのコンストラクターが呼び出されます。

を使用 ConstructorBuilder して動的型のコンストラクターを定義する場合、パラメーターなしのコンストラクターは提供されません。 定義したコンストラクターに加えて、パラメーターなしのコンストラクターを提供するには、次のオプションがあります。

  • 基底クラスのパラメーターなしのコンストラクターを単に呼び出すパラメーターなしのコンストラクターが必要な場合は、 メソッドを TypeBuilder.DefineDefaultConstructor 使用して作成できます (必要に応じてアクセスを制限することもできます)。 このパラメーターなしのコンストラクターの実装は指定しないでください。 その場合、コンストラクターを使用しようとすると例外がスローされます。 メソッドが呼び出されたときに TypeBuilder.CreateType 例外はスローされません。

  • 単に基底クラスのパラメーターなしのコンストラクターを呼び出す以外の何かを行うパラメーターなしのコンストラクター、または基底クラスの別のコンストラクターを呼び出す場合、または他の何かを完全に実行する場合は、 メソッドを TypeBuilder.DefineConstructor 使用して を ConstructorBuilder作成し、独自の実装を提供する必要があります。

コンストラクター

ConstructorBuilder()

ConstructorBuilder クラスの新しいインスタンスを初期化します。

プロパティ

Attributes

このコンストラクターの属性を取得します。

CallingConvention

宣言する型がジェネリックかどうかに依存する CallingConventions の値を取得します。

CallingConvention

このメソッドの呼び出し規約を示す値を取得します。

(継承元 MethodBase)
ContainsGenericParameters

ジェネリック メソッドに、割り当てられていないジェネリック型パラメーターが含まれているかどうかを示す値を取得します。

(継承元 MethodBase)
CustomAttributes

このメンバーのカスタム属性を含むコレクションを取得します。

(継承元 MemberInfo)
DeclaringType

このメンバーを宣言する型の Type オブジェクトへの参照を取得します。

InitLocals

このコンストラクターのローカル変数をゼロに初期化する必要があるかどうかを取得または設定します。

InitLocalsCore

派生クラスでオーバーライドされると、このコンストラクター内のローカル変数をゼロ初期化する必要があるかどうかを示す値を取得または設定します。

IsAbstract

メソッドが抽象メソッドかどうかを示す値を取得します。

(継承元 MethodBase)
IsAssembly

このメソッドまたはコンストラクターを参照できる範囲が Assembly によって示されるかどうかを表す値を取得します。ここで判定されるのは、このメソッドまたはコンストラクターが同じアセンブリ内の他の型でのみ参照でき、アセンブリ外部の派生型では参照できないものであることです。

(継承元 MethodBase)
IsCollectible

この MemberInfo オブジェクトが、収集可能な AssemblyLoadContext に保持されているアセンブリの一部であるかどうかを示す値を取得します。

(継承元 MemberInfo)
IsConstructedGenericMethod

動的クラスのコンストラクターを定義し、表します。

(継承元 MethodBase)
IsConstructor

メソッドがコンストラクターかどうかを示す値を取得します。

(継承元 MethodBase)
IsFamily

このメソッドまたはコンストラクターへの参照範囲が Family によって正しく示されるかどうかを表す値を取得します。ここで判定されるのは、メソッドまたはコンストラクターはそれらのクラスと派生クラスの内側でのみ参照できるものであることです。

(継承元 MethodBase)
IsFamilyAndAssembly

このメソッドまたはコンストラクターへの参照範囲が FamANDAssem によって示されるかどうかを表す値を取得します。ここで判定されるのは、メソッドまたはコンストラクターは派生クラスから呼び出すことができるが、それらが同じアセンブリ内にある場合に限るものであることです。

(継承元 MethodBase)
IsFamilyOrAssembly

このメソッドまたはコンストラクターを参照可能な範囲が FamORAssem によって示されるかどうかを表す値を取得します。ここで判定されるのは、メソッドまたはコンストラクターは任意の場所にある派生クラスと、同じアセンブリ内のクラスから呼び出すことができるものであることです。

(継承元 MethodBase)
IsFinal

このメソッドが final かどうかを示す値を取得します。

(継承元 MethodBase)
IsGenericMethod

メソッドがジェネリック メソッドかどうかを示す値を取得します。

(継承元 MethodBase)
IsGenericMethodDefinition

メソッドがジェネリック メソッドの定義かどうかを示す値を取得します。

(継承元 MethodBase)
IsHideBySig

派生クラスで、正確に同じシグネチャを持つ同じ種類のメンバーだけが隠しメンバーになるかどうかを示す値を取得します。

(継承元 MethodBase)
IsPrivate

このメンバーがプライベートかどうかを示す値を取得します。

(継承元 MethodBase)
IsPublic

パブリック メソッドかどうかを示す値を取得します。

(継承元 MethodBase)
IsSecurityCritical

現在のメソッドまたはコンストラクターが、現在の信頼レベルでセキュリティ クリティカルまたはセキュリティ セーフ クリティカルであり、重要な操作を実行できるかどうかを示す値を取得します。

(継承元 MethodBase)
IsSecuritySafeCritical

現在のメソッドまたはコンストラクターが、現在の信頼レベルでセキュリティ セーフ クリティカルであり、重要な操作を実行でき、透過的なコードからアクセスできるかどうかを示す値を取得します。

(継承元 MethodBase)
IsSecurityTransparent

現在のメソッドまたはコンストラクターが、現在の信頼レベルで透過的であり、重要な操作を実行できないかどうかを示す値を取得します。

(継承元 MethodBase)
IsSpecialName

特別な名前のメソッドかどうかを示す値を取得します。

(継承元 MethodBase)
IsStatic

メソッドが static であるかどうかを示す値を取得します。

(継承元 MethodBase)
IsVirtual

メソッドが virtual であるかどうかを示す値を取得します。

(継承元 MethodBase)
MemberType

このメンバーがコンストラクターであることを示す MemberTypes 値を取得します。

(継承元 ConstructorInfo)
MetadataToken

メタデータ内の現在の動的モジュールを識別するトークンを取得します。

MetadataToken

メタデータ要素を識別する値を取得します。

(継承元 MemberInfo)
MethodHandle

メソッドの内部ハンドルを取得します。 基になるメタデータ ハンドルにアクセスするには、このハンドルを使用します。

MethodHandle

メソッドの内部メタデータ表現を識別するハンドルを取得します。

(継承元 MethodBase)
MethodImplementationFlags

メソッド実装の属性を指定する MethodImplAttributes フラグを取得します。

MethodImplementationFlags

メソッド実装の属性を指定する MethodImplAttributes フラグを取得します。

(継承元 MethodBase)
Module

このコンストラクターが定義されている動的モジュールを取得します。

Module

現在の MemberInfo によって表されるメンバーを宣言する型が定義されているモジュールを取得します。

(継承元 MemberInfo)
Name

このコンストラクターの名前を取得します。

ReflectedType

このオブジェクトの取得元となった Type オブジェクトへの参照を保持します。

ReflectedType

MemberInfo のこのインスタンスを取得するために使用したクラス オブジェクトを取得します。

(継承元 MemberInfo)
ReturnType
古い.

null を取得します。

Signature

文字列の形式でフィールドの署名を取得します。

メソッド

AddDeclarativeSecurity(SecurityAction, PermissionSet)

このコンストラクターに宣言セキュリティを追加します。

DefineParameter(Int32, ParameterAttributes, String)

このコンストラクターのパラメーターを定義します。

DefineParameterCore(Int32, ParameterAttributes, String)

派生クラスでオーバーライドされた場合、このコンストラクターのパラメーターを定義します。

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 ConstructorInfo)
GetCustomAttributes(Boolean)

このコンストラクターに定義済みのカスタム属性をすべて返します。

GetCustomAttributes(Boolean)

派生クラスでオーバーライドされた場合、このメンバーに適用されているすべてのカスタム属性の配列を返します。

(継承元 MemberInfo)
GetCustomAttributes(Type, Boolean)

指定された型で識別されるカスタム属性を返します。

GetCustomAttributes(Type, Boolean)

派生クラスでオーバーライドされた場合は、このメンバーに適用され、Type によって識別されるカスタム属性の配列を返します。

(継承元 MemberInfo)
GetCustomAttributesData()

ターゲット メンバーに適用されている属性に関するデータを表す CustomAttributeData オブジェクトのリストを返します。

(継承元 MemberInfo)
GetGenericArguments()

ジェネリック メソッドの型引数、またはジェネリック メソッドの定義の型パラメーターを表す Type オブジェクトの配列を返します。

(継承元 MethodBase)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 ConstructorInfo)
GetILGenerator()

このコンストラクターの ILGenerator を取得します。

GetILGenerator(Int32)

指定された MSIL ストリーム サイズの ILGenerator オブジェクトを取得します。これは、このコンストラクターのためのメソッド本体をビルドするために使用できます。

GetILGeneratorCore(Int32)

派生クラスでオーバーライドされると、このコンストラクターのメソッド本体を出力するために使用できる を取得 ILGenerator します。

GetMethodBody()

派生クラスでオーバーライドされると、現在のメソッドの MSIL ストリーム、ローカル変数、および例外にアクセスできるようにする MethodBody オブジェクトを取得します。

(継承元 MethodBase)
GetMethodImplementationFlags()

このコンストラクターのメソッド実装フラグを返します。

GetMethodImplementationFlags()

派生クラスでオーバーライドされると、新しい MethodImplAttributes フラグを返します。

(継承元 MethodBase)
GetModule()

このコンストラクターを含むモジュールへの参照を返します。

GetParameters()

このコンストラクターのパラメーターを返します。

GetToken()

このコンストラクターのトークンを表す MethodToken を返します。

GetType()

クラス コンストラクターの属性を検出し、コンス トラクター メタデータへのアクセスを提供します。

(継承元 ConstructorInfo)
HasSameMetadataDefinitionAs(MemberInfo)

動的クラスのコンストラクターを定義し、表します。

(継承元 MemberInfo)
Invoke(BindingFlags, Binder, Object[], CultureInfo)

特定のオブジェクト上のインスタンスによって表されるコンストラクターを動的に呼び出します。その際、指定されたバインダーの制約下で、指定されたパラメーターを一緒に渡します。

Invoke(BindingFlags, Binder, Object[], CultureInfo)

派生クラスに実装された場合、指定されている ConstructorInfo の制約下で、Binder によってリフレクションされるコンストラクターを引数を指定して呼び出します。

(継承元 ConstructorInfo)
Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

指定された Binder の制約下において、指定された引数で、このインスタンスによって反映されるコンストラクターを動的に呼び出します。

Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

派生クラスによってオーバーライドされた場合に、指定したパラメーターでリフレクションされたメソッドまたはコンストラクターを呼び出します。

(継承元 MethodBase)
Invoke(Object, Object[])

指定されたパラメーターを使用して、現在のインスタンスが表すメソッドまたはコンストラクターを呼び出します。

(継承元 MethodBase)
Invoke(Object[])

通常は使用しないパラメーターの既定値を指定して、指定されたパラメーターを持つインスタンスがリフレクトしたコンストラクターを呼び出します。

(継承元 ConstructorInfo)
IsDefined(Type, Boolean)

指定されたカスタム属性の型が定義されているかどうかを確認します。

IsDefined(Type, Boolean)

派生クラスでオーバーライドされた場合、このメンバーに、指定された型の属性またはその派生型の属性が 1 つ以上適用されているかどうかを示します。

(継承元 MemberInfo)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
SetCustomAttribute(ConstructorInfo, Byte[])

指定されたカスタム属性の blob を使用して、カスタム属性を設定します。

SetCustomAttribute(CustomAttributeBuilder)

カスタム属性ビルダーを使用して、カスタム属性を設定します。

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

派生クラスでオーバーライドされた場合は、このコンストラクターにカスタム属性を設定します。

SetImplementationFlags(MethodImplAttributes)

このコンストラクターのメソッド実装フラグを設定します。

SetImplementationFlagsCore(MethodImplAttributes)

派生クラスでオーバーライドされた場合は、このコンストラクターのメソッド実装フラグを設定します。

SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>)

Microsoft intermediate language (MSIL) の命令の指定したバイト配列を使用して、コンストラクターの本体を作成します。

SetSymCustomAttribute(String, Byte[])

シンボル情報に関連付けられているこのコンストラクターのカスタム属性を設定します。

ToString()

この ConstructorBuilder インスタンスを String として返します。

明示的なインターフェイスの実装

_ConstructorBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

_ConstructorBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この型情報を使用して、インターフェイスの型情報を取得できます。

_ConstructorBuilder.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

_ConstructorBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

_ConstructorInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 ConstructorInfo)
_ConstructorInfo.GetType()

Type 型を表す ConstructorInfo オブジェクトを取得します。

(継承元 ConstructorInfo)
_ConstructorInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この型情報を使用して、インターフェイスの型情報を取得できます。

(継承元 ConstructorInfo)
_ConstructorInfo.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 ConstructorInfo)
_ConstructorInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 ConstructorInfo)
_ConstructorInfo.Invoke_2(Object, BindingFlags, Binder, Object[], CultureInfo)

COM オブジェクトに、Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) メソッドへのバージョンに依存しないアクセスが用意されています。

(継承元 ConstructorInfo)
_ConstructorInfo.Invoke_3(Object, Object[])

COM オブジェクトに、Invoke(Object, Object[]) メソッドへのバージョンに依存しないアクセスが用意されています。

(継承元 ConstructorInfo)
_ConstructorInfo.Invoke_4(BindingFlags, Binder, Object[], CultureInfo)

COM オブジェクトに、Invoke(BindingFlags, Binder, Object[], CultureInfo) メソッドへのバージョンに依存しないアクセスが用意されています。

(継承元 ConstructorInfo)
_ConstructorInfo.Invoke_5(Object[])

COM オブジェクトに、Invoke(Object[]) メソッドへのバージョンに依存しないアクセスが用意されています。

(継承元 ConstructorInfo)
_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 MemberInfo)
_MemberInfo.GetType()

Type クラスを表す MemberInfo オブジェクトを取得します。

(継承元 MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この型情報を使用して、インターフェイスの型情報を取得できます。

(継承元 MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 MemberInfo)
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 MethodBase)
_MethodBase.GetType()

このメンバーの詳細については、「GetType()」をご覧ください。

(継承元 MethodBase)
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この型情報を使用して、インターフェイスの型情報を取得できます。

(継承元 MethodBase)
_MethodBase.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 MethodBase)
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 MethodBase)
_MethodBase.IsAbstract

このメンバーの詳細については、「IsAbstract」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsAssembly

このメンバーの詳細については、「IsAssembly」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsConstructor

このメンバーの詳細については、「IsConstructor」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsFamily

このメンバーの詳細については、「IsFamily」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsFamilyAndAssembly

このメンバーの詳細については、「IsFamilyAndAssembly」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsFamilyOrAssembly

このメンバーの詳細については、「IsFamilyOrAssembly」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsFinal

このメンバーの詳細については、「IsFinal」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsHideBySig

このメンバーの詳細については、「IsHideBySig」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsPrivate

このメンバーの詳細については、「IsPrivate」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsPublic

このメンバーの詳細については、「IsPublic」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsSpecialName

このメンバーの詳細については、「IsSpecialName」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsStatic

このメンバーの詳細については、「IsStatic」をご覧ください。

(継承元 MethodBase)
_MethodBase.IsVirtual

このメンバーの詳細については、「IsVirtual」をご覧ください。

(継承元 MethodBase)
ICustomAttributeProvider.GetCustomAttributes(Boolean)

名前付きの属性を除く、このメンバーに定義されているすべてのカスタム属性の配列、またはカスタム属性がない場合は空の配列を返します。

(継承元 MemberInfo)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

型で識別された、このメンバーに定義されているカスタム属性の配列、または、この型のカスタム属性がない場合は空の配列を返します。

(継承元 MemberInfo)
ICustomAttributeProvider.IsDefined(Type, Boolean)

attributeType の 1 つ以上のインスタンスがこのメンバーで定義されているかどうかを示します。

(継承元 MemberInfo)

拡張メソッド

GetCustomAttribute(MemberInfo, Type)

指定したメンバーに適用される指定した型のカスタム属性を取得します。

GetCustomAttribute(MemberInfo, Type, Boolean)

指定したメンバーに適用される指定した型のカスタム属性を取得し、オプションでそのメンバーの先祖を調べます。

GetCustomAttribute<T>(MemberInfo)

指定したメンバーに適用される指定した型のカスタム属性を取得します。

GetCustomAttribute<T>(MemberInfo, Boolean)

指定したメンバーに適用される指定した型のカスタム属性を取得し、オプションでそのメンバーの先祖を調べます。

GetCustomAttributes(MemberInfo)

指定されたメンバーに適用されるカスタム属性のコレクションを取得します。

GetCustomAttributes(MemberInfo, Boolean)

指定されたメンバーに適用されるカスタム属性のコレクションを取得し、オプションでそのメンバーの先祖を調べます。

GetCustomAttributes(MemberInfo, Type)

指定されたメンバーに適用される指定された型のカスタム属性のコレクションを取得します。

GetCustomAttributes(MemberInfo, Type, Boolean)

指定されたメンバーに適用されている指定された型のカスタム属性のコレクションを取得し、オプションでそのメンバーの先祖を調べます。

GetCustomAttributes<T>(MemberInfo)

指定されたメンバーに適用される指定された型のカスタム属性のコレクションを取得します。

GetCustomAttributes<T>(MemberInfo, Boolean)

指定されたメンバーに適用されている指定された型のカスタム属性のコレクションを取得し、オプションでそのメンバーの先祖を調べます。

IsDefined(MemberInfo, Type)

指定された型のカスタム属性が指定されたメンバーに適用されているかどうかを示します。

IsDefined(MemberInfo, Type, Boolean)

指定された型のカスタム属性が指定されたメンバーに適用され、オプションで先祖に適用されているかどうかを示します。

GetMetadataToken(MemberInfo)

指定されたメンバーのメタデータ トークンを取得します (存在する場合)。

HasMetadataToken(MemberInfo)

指定されたメンバーに対してメタデータ トークンを使用できるかどうかを示す値を返します。

適用対象