DynamicMethod クラス

定義

コンパイル、実行、および破棄できる動的メソッドを定義して表します。 破棄されたメソッドは、ガベージ コレクションで使用できます。

public ref class DynamicMethod sealed : System::Reflection::MethodInfo
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DynamicMethod : System.Reflection.MethodInfo
public sealed class DynamicMethod : System.Reflection.MethodInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
type DynamicMethod = class
    inherit MethodInfo
type DynamicMethod = class
    inherit MethodInfo
Public NotInheritable Class DynamicMethod
Inherits MethodInfo
継承
属性

次のコード例では、2 つのパラメーターを受け取る動的メソッドを作成します。 この例では、最初のパラメーターをコンソールに出力する単純な関数本体を出力し、2 番目のパラメーターをメソッドの戻り値として使用します。 この例では、デリゲートを作成してメソッドを完成させ、さまざまなパラメーターでデリゲートを呼び出し、最後に Invoke メソッドを使用して動的メソッドを呼び出します。

using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;

public class Test
{
    // Declare a delegate type that can be used to execute the completed
    // dynamic method.
    private delegate int HelloDelegate(string msg, int ret);

    public static void Main()
    {
        // Create an array that specifies the types of the parameters
        // of the dynamic method. This dynamic method has a String
        // parameter and an Integer parameter.
        Type[] helloArgs = {typeof(string), typeof(int)};

        // Create a dynamic method with the name "Hello", a return type
        // of Integer, and two parameters whose types are specified by
        // the array helloArgs. Create the method in the module that
        // defines the String class.
        DynamicMethod hello = new DynamicMethod("Hello",
            typeof(int),
            helloArgs,
            typeof(string).Module);

        // Create an array that specifies the parameter types of the
        // overload of Console.WriteLine to be used in Hello.
        Type[] writeStringArgs = {typeof(string)};
        // Get the overload of Console.WriteLine that has one
        // String parameter.
        MethodInfo writeString = typeof(Console).GetMethod("WriteLine",
            writeStringArgs);

        // Get an ILGenerator and emit a body for the dynamic method,
        // using a stream size larger than the IL that will be
        // emitted.
        ILGenerator il = hello.GetILGenerator(256);
        // Load the first argument, which is a string, onto the stack.
        il.Emit(OpCodes.Ldarg_0);
        // Call the overload of Console.WriteLine that prints a string.
        il.EmitCall(OpCodes.Call, writeString, null);
        // The Hello method returns the value of the second argument;
        // to do this, load the onto the stack and return.
        il.Emit(OpCodes.Ldarg_1);
        il.Emit(OpCodes.Ret);

        // Add parameter information to the dynamic method. (This is not
        // necessary, but can be useful for debugging.) For each parameter,
        // identified by position, supply the parameter attributes and a
        // parameter name.
        hello.DefineParameter(1, ParameterAttributes.In, "message");
        hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn");

        // Create a delegate that represents the dynamic method. This
        // action completes the method. Any further attempts to
        // change the method are ignored.
        HelloDelegate hi =
            (HelloDelegate) hello.CreateDelegate(typeof(HelloDelegate));

        // Use the delegate to execute the dynamic method.
        Console.WriteLine("\r\nUse the delegate to execute the dynamic method:");
        int retval = hi("\r\nHello, World!", 42);
        Console.WriteLine("Invoking delegate hi(\"Hello, World!\", 42) returned: " + retval);

        // Execute it again, with different arguments.
        retval = hi("\r\nHi, Mom!", 5280);
        Console.WriteLine("Invoking delegate hi(\"Hi, Mom!\", 5280) returned: " + retval);

        Console.WriteLine("\r\nUse the Invoke method to execute the dynamic method:");
        // Create an array of arguments to use with the Invoke method.
        object[] invokeArgs = {"\r\nHello, World!", 42};
        // Invoke the dynamic method using the arguments. This is much
        // slower than using the delegate, because you must create an
        // array to contain the arguments, and value-type arguments
        // must be boxed.
        object objRet = hello.Invoke(null, BindingFlags.ExactBinding, null, invokeArgs, new CultureInfo("en-us"));
        Console.WriteLine("hello.Invoke returned: " + objRet);

        Console.WriteLine("\r\n ----- Display information about the dynamic method -----");
        // Display MethodAttributes for the dynamic method, set when
        // the dynamic method was created.
        Console.WriteLine("\r\nMethod Attributes: {0}", hello.Attributes);

        // Display the calling convention of the dynamic method, set when the
        // dynamic method was created.
        Console.WriteLine("\r\nCalling convention: {0}", hello.CallingConvention);

        // Display the declaring type, which is always null for dynamic
        // methods.
        if (hello.DeclaringType == null)
        {
            Console.WriteLine("\r\nDeclaringType is always null for dynamic methods.");
        }
        else
        {
            Console.WriteLine("DeclaringType: {0}", hello.DeclaringType);
        }

        // Display the default value for InitLocals.
        if (hello.InitLocals)
        {
            Console.Write("\r\nThis method contains verifiable code.");
        }
        else
        {
            Console.Write("\r\nThis method contains unverifiable code.");
        }
        Console.WriteLine(" (InitLocals = {0})", hello.InitLocals);

        // Display the module specified when the dynamic method was created.
        Console.WriteLine("\r\nModule: {0}", hello.Module);

        // Display the name specified when the dynamic method was created.
        // Note that the name can be blank.
        Console.WriteLine("\r\nName: {0}", hello.Name);

        // For dynamic methods, the reflected type is always null.
        if (hello.ReflectedType == null)
        {
            Console.WriteLine("\r\nReflectedType is null.");
        }
        else
        {
            Console.WriteLine("\r\nReflectedType: {0}", hello.ReflectedType);
        }

        if (hello.ReturnParameter == null)
        {
            Console.WriteLine("\r\nMethod has no return parameter.");
        }
        else
        {
            Console.WriteLine("\r\nReturn parameter: {0}", hello.ReturnParameter);
        }

        // If the method has no return type, ReturnType is System.Void.
        Console.WriteLine("\r\nReturn type: {0}", hello.ReturnType);

        // ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
        // that can be used to enumerate the custom attributes of the
        // return value. At present, there is no way to set such custom
        // attributes, so the list is empty.
        if (hello.ReturnType == typeof(void))
        {
            Console.WriteLine("The method has no return type.");
        }
        else
        {
            ICustomAttributeProvider caProvider = hello.ReturnTypeCustomAttributes;
            object[] returnAttributes = caProvider.GetCustomAttributes(true);
            if (returnAttributes.Length == 0)
            {
                Console.WriteLine("\r\nThe return type has no custom attributes.");
            }
            else
            {
                Console.WriteLine("\r\nThe return type has the following custom attributes:");
                foreach( object attr in returnAttributes )
                {
                    Console.WriteLine("\t{0}", attr.ToString());
                }
            }
        }

        Console.WriteLine("\r\nToString: {0}", hello.ToString());

        // Display parameter information.
        ParameterInfo[] parameters = hello.GetParameters();
        Console.WriteLine("\r\nParameters: name, type, ParameterAttributes");
        foreach( ParameterInfo p in parameters )
        {
            Console.WriteLine("\t{0}, {1}, {2}",
                p.Name, p.ParameterType, p.Attributes);
        }
    }
}

/* This code example produces the following output:

Use the delegate to execute the dynamic method:

Hello, World!
Invoking delegate hi("Hello, World!", 42) returned: 42

Hi, Mom!
Invoking delegate hi("Hi, Mom!", 5280) returned: 5280

Use the Invoke method to execute the dynamic method:

Hello, World!
hello.Invoke returned: 42

 ----- Display information about the dynamic method -----

Method Attributes: PrivateScope, Public, Static

Calling convention: Standard

DeclaringType is always null for dynamic methods.

This method contains verifiable code. (InitLocals = True)

Module: CommonLanguageRuntimeLibrary

Name: Hello

ReflectedType is null.

Method has no return parameter.

Return type: System.Int32

The return type has no custom attributes.

ToString: Int32 Hello(System.String, Int32)

Parameters: name, type, ParameterAttributes
        message, System.String, In
        valueToReturn, System.Int32, In
 */
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Globalization

Public Class Test
    ' Declare a delegate type that can be used to execute the completed
    ' dynamic method. 
    Private Delegate Function HelloDelegate(ByVal msg As String, _
        ByVal ret As Integer) As Integer

    Public Shared Sub Main()
        ' Create an array that specifies the types of the parameters
        ' of the dynamic method. This dynamic method has a String
        ' parameter and an Integer parameter.
        Dim helloArgs() As Type = {GetType(String), GetType(Integer)}

        ' Create a dynamic method with the name "Hello", a return type
        ' of Integer, and two parameters whose types are specified by
        ' the array helloArgs. Create the method in the module that
        ' defines the String class.
        Dim hello As New DynamicMethod("Hello", _
            GetType(Integer), _
            helloArgs, _
            GetType(String).Module)

        ' Create an array that specifies the parameter types of the
        ' overload of Console.WriteLine to be used in Hello.
        Dim writeStringArgs() As Type = {GetType(String)}
        ' Get the overload of Console.WriteLine that has one
        ' String parameter.
        Dim writeString As MethodInfo = GetType(Console). _
            GetMethod("WriteLine", writeStringArgs) 

        ' Get an ILGenerator and emit a body for the dynamic method,
        ' using a stream size larger than the IL that will be
        ' emitted.
        Dim il As ILGenerator = hello.GetILGenerator(256)
        ' Load the first argument, which is a string, onto the stack.
        il.Emit(OpCodes.Ldarg_0)
        ' Call the overload of Console.WriteLine that prints a string.
        il.EmitCall(OpCodes.Call, writeString, Nothing)
        ' The Hello method returns the value of the second argument;
        ' to do this, load the onto the stack and return.
        il.Emit(OpCodes.Ldarg_1)
        il.Emit(OpCodes.Ret)

        ' Add parameter information to the dynamic method. (This is not
        ' necessary, but can be useful for debugging.) For each parameter,
        ' identified by position, supply the parameter attributes and a 
        ' parameter name.
        hello.DefineParameter(1, ParameterAttributes.In, "message")
        hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn")

        ' Create a delegate that represents the dynamic method. This
        ' action completes the method. Any further attempts to
        ' change the method are ignored.
    Dim hi As HelloDelegate = _
            CType(hello.CreateDelegate(GetType(HelloDelegate)), HelloDelegate)

        ' Use the delegate to execute the dynamic method.
        Console.WriteLine(vbCrLf & "Use the delegate to execute the dynamic method:")
        Dim retval As Integer = hi(vbCrLf & "Hello, World!", 42)
        Console.WriteLine("Invoking delegate hi(""Hello, World!"", 42) returned: " _
            & retval & ".")

        ' Execute it again, with different arguments.
        retval = hi(vbCrLf & "Hi, Mom!", 5280)
        Console.WriteLine("Invoking delegate hi(""Hi, Mom!"", 5280) returned: " _
            & retval & ".")

        Console.WriteLine(vbCrLf & "Use the Invoke method to execute the dynamic method:")
        ' Create an array of arguments to use with the Invoke method.
        Dim invokeArgs() As Object = {vbCrLf & "Hello, World!", 42}
        ' Invoke the dynamic method using the arguments. This is much
        ' slower than using the delegate, because you must create an
        ' array to contain the arguments, and value-type arguments
        ' must be boxed.
        Dim objRet As Object = hello.Invoke(Nothing, _
            BindingFlags.ExactBinding, Nothing, invokeArgs, _
            New CultureInfo("en-us"))
        Console.WriteLine("hello.Invoke returned: {0}", objRet)

        Console.WriteLine(vbCrLf & _
            " ----- Display information about the dynamic method -----")
        ' Display MethodAttributes for the dynamic method, set when 
        ' the dynamic method was created.
        Console.WriteLine(vbCrLf & "Method Attributes: {0}", _
            hello.Attributes)

        ' Display the calling convention of the dynamic method, set when the 
        ' dynamic method was created.
        Console.WriteLine(vbCrLf & "Calling convention: {0}", _ 
            hello.CallingConvention)

        ' Display the declaring type, which is always Nothing for dynamic
        ' methods.
        If hello.DeclaringType Is Nothing Then
            Console.WriteLine(vbCrLf & "DeclaringType is always Nothing for dynamic methods.")
        Else
            Console.WriteLine("DeclaringType: {0}", hello.DeclaringType)
        End If

        ' Display the default value for InitLocals.
        If hello.InitLocals Then
            Console.Write(vbCrLf & "This method contains verifiable code.")
        Else
            Console.Write(vbCrLf & "This method contains unverifiable code.")
        End If
        Console.WriteLine(" (InitLocals = {0})", hello.InitLocals)

        ' Display the module specified when the dynamic method was created.
        Console.WriteLine(vbCrLf & "Module: {0}", hello.Module)

        ' Display the name specified when the dynamic method was created.
        ' Note that the name can be blank.
        Console.WriteLine(vbCrLf & "Name: {0}", hello.Name)

        ' For dynamic methods, the reflected type is always Nothing.
        If hello.ReflectedType Is Nothing Then
            Console.WriteLine(vbCrLf & "ReflectedType is Nothing.")
        Else
            Console.WriteLine(vbCrLf & "ReflectedType: {0}", _
                hello.ReflectedType)
        End If

        If hello.ReturnParameter Is Nothing Then
            Console.WriteLine(vbCrLf & "Method has no return parameter.")
        Else
            Console.WriteLine(vbCrLf & "Return parameter: {0}", _
                hello.ReturnParameter)
        End If

        ' If the method has no return type, ReturnType is System.Void.
        Console.WriteLine(vbCrLf & "Return type: {0}", hello.ReturnType)           

        ' ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
        ' that can be used to enumerate the custom attributes of the
        ' return value. At present, there is no way to set such custom
        ' attributes, so the list is empty.
        If hello.ReturnType Is GetType(System.Void) Then
            Console.WriteLine("The method has no return type.")
        Else
            Dim caProvider As ICustomAttributeProvider = _
                hello.ReturnTypeCustomAttributes
            Dim returnAttributes() As Object = _
                caProvider.GetCustomAttributes(True)
            If returnAttributes.Length = 0 Then
                Console.WriteLine(vbCrLf _
                    & "The return type has no custom attributes.")
            Else
                Console.WriteLine(vbCrLf _
                    & "The return type has the following custom attributes:")
                For Each attr As Object In returnAttributes
                    Console.WriteLine(vbTab & attr.ToString())
                Next attr
            End If
        End If

        Console.WriteLine(vbCrLf & "ToString: " & hello.ToString())

        ' Display parameter information.
        Dim parameters() As ParameterInfo = hello.GetParameters()
        Console.WriteLine(vbCrLf & "Parameters: name, type, ParameterAttributes")
        For Each p As ParameterInfo In parameters
            Console.WriteLine(vbTab & "{0}, {1}, {2}", _ 
                p.Name, p.ParameterType, p.Attributes)
        Next p
    End Sub
End Class

' This code example produces the following output:
'
'Use the delegate to execute the dynamic method:
'
'Hello, World!
'Invoking delegate hi("Hello, World!", 42) returned: 42.
'
'Hi, Mom!
'Invoking delegate hi("Hi, Mom!", 5280) returned: 5280.
'
'Use the Invoke method to execute the dynamic method:
'
'Hello, World!
'hello.Invoke returned: 42
'
' ----- Display information about the dynamic method -----
'
'Method Attributes: PrivateScope, Public, Static
'
'Calling convention: Standard
'
'DeclaringType is always Nothing for dynamic methods.
'
'This method contains verifiable code. (InitLocals = True)
'
'Module: CommonLanguageRuntimeLibrary
'
'Name: Hello
'
'ReflectedType is Nothing.
'
'Method has no return parameter.
'
'Return type: System.Int32
'
'The return type has no custom attributes.
'
'ToString: Int32 Hello(System.String, Int32)
'
'Parameters: name, type, ParameterAttributes
'        message, System.String, In
'        valueToReturn, System.Int32, In

注釈

この API の詳細については、「 DynamicMethod の補足 API 解説」を参照してください。

コンストラクター

名前 説明
DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean)

メソッド名、属性、呼び出し規則、戻り値の型、パラメーター型、モジュール、および動的メソッドのMicrosoft中間言語 (MSIL) によってアクセスされる型とメンバーに対して Just-In-Time (JIT) 可視性チェックをスキップするかどうかを指定して、モジュールにグローバルな動的メソッドを作成します。

DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type, Boolean)

動的メソッドを作成し、メソッド名、属性、呼び出し規則、戻り値の型、パラメーター型、動的メソッドが論理的に関連付けられている型、および動的メソッドのMicrosoft中間言語 (MSIL) によってアクセスされる型とメンバーに対して Just-In-Time (JIT) 可視性チェックをスキップするかどうかを指定します。

DynamicMethod(String, Type, Type[], Boolean)

匿名でホストされる動的メソッドを初期化し、メソッド名、戻り値の型、パラメーターの型、および動的メソッドのMicrosoft中間言語 (MSIL) によってアクセスされる型とメンバーの Just-In-Time (JIT) 可視性チェックをスキップするかどうかを指定します。

DynamicMethod(String, Type, Type[], Module, Boolean)

メソッド名、戻り値の型、パラメーター型、モジュール、および動的メソッドのMicrosoft中間言語 (MSIL) によってアクセスされる型とメンバーに対して Just-In-Time (JIT) 可視性チェックをスキップするかどうかを指定して、モジュールにグローバルな動的メソッドを作成します。

DynamicMethod(String, Type, Type[], Module)

メソッド名、戻り値の型、パラメーター型、およびモジュールを指定して、モジュールに対してグローバルな動的メソッドを作成します。

DynamicMethod(String, Type, Type[], Type, Boolean)

動的メソッドを作成し、メソッド名、戻り値の型、パラメーター型、動的メソッドが論理的に関連付けられている型、および動的メソッドのMicrosoft中間言語 (MSIL) によってアクセスされる型とメンバーに対して Just-In-Time (JIT) 可視性チェックをスキップするかどうかを指定します。

DynamicMethod(String, Type, Type[], Type)

動的メソッドを作成し、メソッド名、戻り値の型、パラメーター型、および動的メソッドが論理的に関連付けられている型を指定します。

DynamicMethod(String, Type, Type[])

メソッド名、戻り値の型、およびパラメーター型を指定して、匿名でホストされる動的メソッドを初期化します。

プロパティ

名前 説明
Attributes

動的メソッドの作成時に指定された属性を取得します。

CallingConvention

動的メソッドの作成時に指定された呼び出し規則を取得します。

ContainsGenericParameters

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

(継承元 MethodInfo)
CustomAttributes

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

(継承元 MemberInfo)
DeclaringType

動的メソッドに対して常に null されるメソッドを宣言する型を取得します。

InitLocals

メソッド内のローカル変数がゼロ初期化されているかどうかを示す値を取得または設定します。

IsAbstract

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

(継承元 MethodBase)
IsAssembly

このメソッドまたはコンストラクターの潜在的な可視性が Assemblyによって記述されているかどうかを示す値を取得します。つまり、メソッドまたはコンストラクターは、同じアセンブリ内の他の型に対して最大で表示され、アセンブリ外の派生型には表示されません。

(継承元 MethodBase)
IsConstructedGenericMethod

コンパイル、実行、および破棄できる動的メソッドを定義して表します。 破棄されたメソッドは、ガベージ コレクションで使用できます。

(継承元 MethodBase)
IsConstructor

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

(継承元 MethodBase)
IsFamily

このメソッドまたはコンストラクターの可視性が Familyによって記述されているかどうかを示す値を取得します。つまり、メソッドまたはコンストラクターは、そのクラスおよび派生クラス内でのみ表示されます。

(継承元 MethodBase)
IsFamilyAndAssembly

このメソッドまたはコンストラクターの可視性が FamANDAssemによって記述されているかどうかを示す値を取得します。つまり、メソッドまたはコンストラクターは派生クラスによって呼び出すことができますが、同じアセンブリ内にある場合にのみ呼び出すことができます。

(継承元 MethodBase)
IsFamilyOrAssembly

このメソッドまたはコンストラクターの潜在的な可視性が FamORAssemによって記述されているかどうかを示す値を取得します。つまり、メソッドまたはコンストラクターは、どこにいても派生クラス、および同じアセンブリ内のクラスによって呼び出すことができます。

(継承元 MethodBase)
IsFinal

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

(継承元 MethodBase)
IsGenericMethod

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

(継承元 MethodInfo)
IsGenericMethodDefinition

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

(継承元 MethodInfo)
IsHideBySig

まったく同じシグネチャを持つ同じ種類のメンバーのみが派生クラスで非表示かどうかを示す値を取得します。

(継承元 MethodBase)
IsPrivate

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

(継承元 MethodBase)
IsPublic

これがパブリック メソッドであるかどうかを示す値を取得します。

(継承元 MethodBase)
IsSecurityCritical

現在の動的メソッドがセキュリティ クリティカルかセキュリティ セーフ クリティカルかを示す値を取得します。そのため、重要な操作を実行できます。

IsSecurityCritical

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

(継承元 MethodBase)
IsSecuritySafeCritical

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

IsSecuritySafeCritical

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

(継承元 MethodBase)
IsSecurityTransparent

現在の動的メソッドが現在の信頼レベルで透過的であり、重要な操作を実行できないかどうかを示す値を取得します。

IsSecurityTransparent

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

(継承元 MethodBase)
IsSpecialName

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

(継承元 MethodBase)
IsStatic

メソッドが staticされているかどうかを示す値を取得します。

(継承元 MethodBase)
IsVirtual

メソッドが virtualされているかどうかを示す値を取得します。

(継承元 MethodBase)
MemberType

このメンバーがメソッドであることを示す MemberTypes 値を取得します。

(継承元 MethodInfo)
MetadataToken

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

(継承元 MemberInfo)
MethodHandle

動的メソッドではサポートされていません。

MethodImplementationFlags

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

(継承元 MethodBase)
Module

動的メソッドが論理的に関連付けられているモジュールを取得します。

Module

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

(継承元 MemberInfo)
Name

動的メソッドの名前を取得します。

ReflectedType

リフレクションでメソッドを取得するために使用されたクラスを取得します。

ReturnParameter

動的メソッドの戻り値パラメーターを取得します。

ReturnType

動的メソッドの戻り値の型を取得します。

ReturnTypeCustomAttributes

動的メソッドの戻り値の型のカスタム属性を取得します。

メソッド

名前 説明
CreateDelegate(Type, Object)

動的メソッドを完了し、デリゲートの実行に使用できるデリゲートを作成します。デリゲートの型とデリゲートがバインドされているオブジェクトを指定します。

CreateDelegate(Type)

動的メソッドを完了し、それを実行するために使用できるデリゲートを作成します。

DefineParameter(Int32, ParameterAttributes, String)

動的メソッドのパラメーターを定義します。

Equals(Object)

このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。

(継承元 MethodInfo)
GetBaseDefinition()

メソッドの基本実装を返します。

GetCustomAttributes(Boolean)

メソッドに定義されているすべてのカスタム属性を返します。

GetCustomAttributes(Type, Boolean)

メソッドに適用されている、指定した型のカスタム属性を返します。

GetCustomAttributesData()

ターゲット メンバーに適用 CustomAttributeData 属性に関するデータを表すオブジェクトの一覧を返します。

(継承元 MemberInfo)
GetDynamicILInfo()

メタデータ トークン、スコープ、Microsoft中間言語 (MSIL) ストリームからメソッド本体を生成するために使用できるDynamicILInfo オブジェクトを返します。

GetGenericArguments()

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

(継承元 MethodInfo)
GetGenericMethodDefinition()

現在のメソッドを構築できるジェネリック メソッド定義を表す MethodInfo オブジェクトを返します。

(継承元 MethodInfo)
GetHashCode()

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

(継承元 MethodInfo)
GetILGenerator()

既定の MSIL ストリーム サイズが 64 バイトのメソッドのMicrosoft中間言語 (MSIL) ジェネレーターを返します。

GetILGenerator(Int32)

指定した MSIL ストリーム サイズを持つメソッドのMicrosoft中間言語 (MSIL) ジェネレーターを返します。

GetMethodBody()

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

(継承元 MethodBase)
GetMethodImplementationFlags()

メソッドの実装フラグを返します。

GetParameters()

動的メソッドのパラメーターを返します。

HasSameMetadataDefinitionAs(MemberInfo)

コンパイル、実行、および破棄できる動的メソッドを定義して表します。 破棄されたメソッドは、ガベージ コレクションで使用できます。

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

指定したカルチャ情報を使用して、指定したバインダーの制約の下で、指定したパラメーターを使用して動的メソッドを呼び出します。

IsDefined(Type, Boolean)

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

MakeGenericMethod(Type[])

型の配列の要素を現在のジェネリック メソッド定義の型パラメーターに置き換え、結果として構築されたメソッドを表す MethodInfo オブジェクトを返します。

(継承元 MethodInfo)
MemberwiseClone()

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

(継承元 Object)
ToString()

文字列として表されるメソッドのシグネチャを返します。

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

名前 説明
_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)
_MethodInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

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

(継承元 MethodInfo)
_MethodInfo.GetType()

COM から GetType() メソッドへのアクセスを提供します。

(継承元 MethodInfo)
_MethodInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

インターフェイスの型情報を取得するために使用できるオブジェクトの型情報を取得します。

(継承元 MethodInfo)
_MethodInfo.GetTypeInfoCount(UInt32)

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

(継承元 MethodInfo)
_MethodInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

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

(継承元 MethodInfo)

拡張メソッド

名前 説明
GetCustomAttribute(MemberInfo, Type, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性を取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttribute(MemberInfo, Type)

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

GetCustomAttribute<T>(MemberInfo, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性を取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttribute<T>(MemberInfo)

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

GetCustomAttributes(MemberInfo, Boolean)

指定したメンバーに適用されるカスタム属性のコレクションを取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttributes(MemberInfo, Type, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性のコレクションを取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttributes(MemberInfo, Type)

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

GetCustomAttributes(MemberInfo)

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

GetCustomAttributes<T>(MemberInfo, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性のコレクションを取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttributes<T>(MemberInfo)

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

GetRuntimeBaseDefinition(MethodInfo)

メソッドが最初に宣言されたダイレクト 基底クラスまたは間接基底クラスで、指定されたメソッドを表すオブジェクトを取得します。

IsDefined(MemberInfo, Type, Boolean)

指定した型のカスタム属性が指定したメンバーに適用され、必要に応じてその先祖に適用されるかどうかを示します。

IsDefined(MemberInfo, Type)

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

適用対象

こちらもご覧ください