ConstructorBuilder.GetParameters メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As ConstructorBuilder Dim returnValue As ParameterInfo() returnValue = instance.GetParameters
このコンストラクタのパラメータを表す ParameterInfo オブジェクトの配列を返します。

例外の種類 | 条件 |
---|---|
InvalidOperationException | .NET Framework Version 1.0 および 1.1 では、このコンストラクタの型で CreateType が呼び出されませんでした。 |
NotSupportedException | .NET Framework Version 2.0 では、このコンストラクタの型で CreateType が呼び出されませんでした。 |

このプロパティは、TypeBuilder.CreateType メソッドが呼び出されるまでサポートされません。.NET Framework Version 1.0 および 1.1 では、InvalidOperationException がスローされます。.NET Framework Version 2.0 の場合は、NotSupportedException がスローされます。

GetParameters の使用方法については、次のコード例を参照してください。
' Define a constructor of the dynamic class. Dim myConstructorBuilder As ConstructorBuilder = _ myTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _ myConstructorArgs) ' Get a reference to the module that contains this constructor. Dim myModule As [Module] = myConstructorBuilder.GetModule() Console.WriteLine("Module Name : " + myModule.Name) ' Get the 'MethodToken' that represents the token for this constructor. Dim myMethodToken As MethodToken = myConstructorBuilder.GetToken() Console.WriteLine("Constructor Token is : " + myMethodToken.Token.ToString()) ' Get the method implementation flags for this constructor. Dim myMethodImplAttributes As MethodImplAttributes = _ myConstructorBuilder.GetMethodImplementationFlags() Console.WriteLine("MethodImplAttributes : " + myMethodImplAttributes.ToString()) ' Generate IL for the method, call its base class constructor and store the arguments ' in the private field. Dim myILGenerator3 As ILGenerator = myConstructorBuilder.GetILGenerator() myILGenerator3.Emit(OpCodes.Ldarg_0) Dim myConstructorInfo As ConstructorInfo = GetType(Object).GetConstructor(New Type() {}) myILGenerator3.Emit(OpCodes.Call, myConstructorInfo) myILGenerator3.Emit(OpCodes.Ldarg_0) myILGenerator3.Emit(OpCodes.Ldarg_1) myILGenerator3.Emit(OpCodes.Stfld, myGreetingField) myILGenerator3.Emit(OpCodes.Ret) ' Add a method to the type. myMethodBuilder = _ myTypeBuilder.DefineMethod("HelloWorld", MethodAttributes.Public, Nothing, Nothing) ' Generate IL for the method. Dim myILGenerator2 As ILGenerator = myMethodBuilder.GetILGenerator() myILGenerator2.EmitWriteLine("Hello World from global") myILGenerator2.Emit(OpCodes.Ret) myModuleBuilder.CreateGlobalFunctions() myType1 = myTypeBuilder.CreateType() ' Get the parameters of this constructor. Dim myParameterInfo As ParameterInfo() = myConstructorBuilder.GetParameters() Dim i As Integer For i = 0 To myParameterInfo.Length - 1 Console.WriteLine _ ("Declaration type : " + myParameterInfo(i).Member.DeclaringType.ToString()) Next i
// Define a constructor of the dynamic class. ConstructorBuilder myConstructorBuilder = myTypeBuilder.DefineConstructor( MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs); // Get a reference to the module that contains this constructor. Module myModule = myConstructorBuilder.GetModule(); Console.WriteLine("Module Name : " + myModule.Name); // Get the 'MethodToken' that represents the token for this constructor. MethodToken myMethodToken = myConstructorBuilder.GetToken(); Console.WriteLine("Constructor Token is : " + myMethodToken.Token); // Get the method implementation flags for this constructor. MethodImplAttributes myMethodImplAttributes = myConstructorBuilder.GetMethodImplementationFlags(); Console.WriteLine("MethodImplAttributes : " + myMethodImplAttributes); // Generate IL for the method, call its base class constructor and store the arguments // in the private field. ILGenerator myILGenerator3 = myConstructorBuilder.GetILGenerator(); myILGenerator3.Emit(OpCodes.Ldarg_0); ConstructorInfo myConstructorInfo = typeof(Object).GetConstructor(new Type[0]); myILGenerator3.Emit(OpCodes.Call, myConstructorInfo); myILGenerator3.Emit(OpCodes.Ldarg_0); myILGenerator3.Emit(OpCodes.Ldarg_1); myILGenerator3.Emit(OpCodes.Stfld, myGreetingField); myILGenerator3.Emit(OpCodes.Ret); // Add a method to the type. myMethodBuilder = myTypeBuilder.DefineMethod ("HelloWorld",MethodAttributes.Public,null,null); // Generate IL for the method. ILGenerator myILGenerator2 = myMethodBuilder.GetILGenerator(); myILGenerator2.EmitWriteLine("Hello World from global"); myILGenerator2.Emit(OpCodes.Ret); myModuleBuilder.CreateGlobalFunctions(); myType1 = myTypeBuilder.CreateType(); // Get the parameters of this constructor. ParameterInfo[] myParameterInfo = myConstructorBuilder.GetParameters(); for(int i =0 ; i < myParameterInfo.Length; i++) { Console.WriteLine("Declaration type : " + myParameterInfo[i].Member.DeclaringType); }
// Define a constructor of the dynamic class. ConstructorBuilder^ myConstructorBuilder = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); // Get a reference to the module that contains this constructor. Module^ myModule = myConstructorBuilder->GetModule(); Console::WriteLine( "Module Name : {0}", myModule->Name ); // Get the 'MethodToken' that represents the token for this constructor. MethodToken myMethodToken = myConstructorBuilder->GetToken(); Console::WriteLine( "Constructor Token is : {0}", myMethodToken.Token ); // Get the method implementation flags for this constructor. MethodImplAttributes myMethodImplAttributes = myConstructorBuilder->GetMethodImplementationFlags(); Console::WriteLine( "MethodImplAttributes : {0}", myMethodImplAttributes ); // Generate IL for the method, call its base class constructor and store the arguments // in the private field. ILGenerator^ myILGenerator3 = myConstructorBuilder->GetILGenerator(); myILGenerator3->Emit( OpCodes::Ldarg_0 ); ConstructorInfo^ myConstructorInfo = Object::typeid->GetConstructor( gcnew array<Type^>(0) ); myILGenerator3->Emit( OpCodes::Call, myConstructorInfo ); myILGenerator3->Emit( OpCodes::Ldarg_0 ); myILGenerator3->Emit( OpCodes::Ldarg_1 ); myILGenerator3->Emit( OpCodes::Stfld, myGreetingField ); myILGenerator3->Emit( OpCodes::Ret ); // Add a method to the type. myMethodBuilder = myTypeBuilder->DefineMethod( "HelloWorld", MethodAttributes::Public, nullptr, nullptr ); // Generate IL for the method. ILGenerator^ myILGenerator2 = myMethodBuilder->GetILGenerator(); myILGenerator2->EmitWriteLine( "Hello World from global" ); myILGenerator2->Emit( OpCodes::Ret ); myModuleBuilder->CreateGlobalFunctions(); myType1 = myTypeBuilder->CreateType(); // Get the parameters of this constructor. array<ParameterInfo^>^myParameterInfo = myConstructorBuilder->GetParameters(); for ( int i = 0; i < myParameterInfo->Length; i++ ) { Console::WriteLine( "Declaration type : {0}", myParameterInfo[ i ]->Member->DeclaringType ); }
// Define a constructor of the dynamic class. ConstructorBuilder myConstructorBuilder = myTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs); // Get a reference to the module that contains this constructor. Module myModule = myConstructorBuilder.GetModule(); Console.WriteLine("Module Name : " + myModule.get_Name()); // Get the 'MethodToken' that represents the token for this constructor. MethodToken myMethodToken = myConstructorBuilder.GetToken(); Console.WriteLine("Constructor Token is : " + myMethodToken.get_Token()); // Get the method implementation flags for this constructor. MethodImplAttributes myMethodImplAttributes = myConstructorBuilder.GetMethodImplementationFlags(); Console.WriteLine("MethodImplAttributes : " + myMethodImplAttributes); // Generate IL for the method, call its base class constructor and // store the arguments in the private field. ILGenerator myILGenerator3 = myConstructorBuilder.GetILGenerator(); myILGenerator3.Emit(OpCodes.Ldarg_0); ConstructorInfo myConstructorInfo = Object.class.ToType().GetConstructor(new Type[0]); myILGenerator3.Emit(OpCodes.Call, myConstructorInfo); myILGenerator3.Emit(OpCodes.Ldarg_0); myILGenerator3.Emit(OpCodes.Ldarg_1); myILGenerator3.Emit(OpCodes.Stfld, myGreetingField); myILGenerator3.Emit(OpCodes.Ret); // Add a method to the type. myMethodBuilder = myTypeBuilder.DefineMethod("HelloWorld", MethodAttributes.Public, null, null); // Generate IL for the method. ILGenerator myILGenerator2 = myMethodBuilder.GetILGenerator(); myILGenerator2.EmitWriteLine("Hello World from global"); myILGenerator2.Emit(OpCodes.Ret); myModuleBuilder.CreateGlobalFunctions(); myType1 = myTypeBuilder.CreateType(); // Get the parameters of this constructor. ParameterInfo myParameterInfo[] = myConstructorBuilder.GetParameters(); for (int i = 0; i < myParameterInfo.length; i++) { Console.WriteLine("Declaration type : " + myParameterInfo[i].get_Member().get_DeclaringType()); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からConstructorBuilder.GetParameters メソッドを検索する場合は、下記のリンクをクリックしてください。

- ConstructorBuilder.GetParameters メソッドのページへのリンク