DynamicMethod Osztály

Definíció

Olyan dinamikus metódust definiál és jelöl, amely lefordítható, végrehajtható és elvethető. Az elvetett metódusok a szemétgyűjtéshez érhetők el.

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
Öröklődés
Attribútumok

Példák

Az alábbi példakód egy dinamikus metódust hoz létre, amely két paramétert vesz igénybe. A példa egy egyszerű függvénytörzset bocsát ki, amely az első paramétert a konzolra nyomtatja, a példa pedig a második paramétert használja a metódus visszatérési értékeként. A példa egy delegált létrehozásával fejezi be a metódust, meghívja a delegáltat különböző paraméterekkel, és végül meghívja a dinamikus metódust a Invoke metódus használatával.

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

Megjegyzések

Az API-val kapcsolatos további információkért lásd a DynamicMethod kiegészítő API-megjegyzéseit.

Konstruktorok

Name Description
DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean)

Egy modulra globálisan globális dinamikus metódust hoz létre, amely megadja a metódus nevét, attribútumait, hívási konvencióját, visszatérési típusát, paramétertípusait, moduljait, valamint azt, hogy a dinamikus módszer Microsoft köztes nyelve (MSIL) által elért típusok és tagok esetében kihagyandó-e az igény szerinti (JIT) láthatósági ellenőrzések.

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

Létrehoz egy dinamikus metódust, amely megadja a metódus nevét, attribútumait, hívási konvencióját, visszatérési típusát, paramétertípusait, a dinamikus metódus logikai társításának típusát, valamint azt, hogy a dinamikus módszer Microsoft köztes nyelvével (MSIL) elért típusok és tagok esetében kihagyandó-e az igény szerinti (JIT) láthatósági ellenőrzések.

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

Inicializál egy névtelenül üzemeltetett dinamikus metódust, megadva a metódus nevét, a visszatérési típust, a paramétertípusokat, valamint azt, hogy a dinamikus módszer Microsoft köztes nyelvével (MSIL) elért típusok és tagok esetében kihagyandó-e az igény szerinti (JIT) láthatósági ellenőrzés.

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

Egy modulra globálisan globális dinamikus metódust hoz létre, amely megadja a metódus nevét, a visszatérési típust, a paramétertípusokat, a modult, valamint azt, hogy a dinamikus módszer Microsoft köztes nyelve (MSIL) által elért típusok és tagok esetében ki kell-e hagyni az igény szerinti (JIT) láthatósági ellenőrzéseket.

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

Egy modulra globálisan globális dinamikus metódust hoz létre, amely megadja a metódus nevét, a visszatérés típusát, a paramétertípusokat és a modult.

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

Létrehoz egy dinamikus metódust, amely megadja a metódus nevét, a visszatérési típust, a paramétertípusokat, a dinamikus metódus logikai társításának típusát, valamint azt, hogy a dinamikus metódus Microsoft köztes nyelve (MSIL) által elért típusok és tagok esetében kihagyandó-e az időalapú (JIT) láthatósági ellenőrzések.

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

Létrehoz egy dinamikus metódust, amely megadja a metódus nevét, a visszatérési típust, a paramétertípusokat és azt a típust, amelyhez a dinamikus metódus logikailag társítva van.

DynamicMethod(String, Type, Type[])

Inicializál egy névtelenül üzemeltetett dinamikus metódust, megadva a metódus nevét, a visszatérés típusát és a paramétertípusokat.

Tulajdonságok

Name Description
Attributes

Lekéri a dinamikus metódus létrehozásakor megadott attribútumokat.

CallingConvention

Lekéri a dinamikus metódus létrehozásakor megadott hívási konvenciót.

ContainsGenericParameters

Olyan értéket kap, amely jelzi, hogy egy általános metódus nem hozzárendelt általános típusparamétereket tartalmaz-e.

(Öröklődés forrása MethodInfo)
CustomAttributes

Lekéri a tag egyéni attribútumait tartalmazó gyűjteményt.

(Öröklődés forrása MemberInfo)
DeclaringType

Lekéri azt a típust, amely deklarálja a metódust, amely mindig null dinamikus metódusokhoz tartozik.

InitLocals

Lekéri vagy beállít egy értéket, amely jelzi, hogy a metódus helyi változói nulla inicializálva vannak-e.

IsAbstract

Egy értéket kap, amely jelzi, hogy a metódus absztrakt-e.

(Öröklődés forrása MethodBase)
IsAssembly

Olyan értéket kap, amely jelzi, hogy a metódus vagy a konstruktor lehetséges láthatóságát az határozza-e meg Assembly, hogy a metódus vagy a konstruktor legfeljebb ugyanazon szerelvény más típusai számára látható, és nem látható a szerelvényen kívüli származtatott típusok számára.

(Öröklődés forrása MethodBase)
IsConstructedGenericMethod

Olyan dinamikus metódust definiál és jelöl, amely lefordítható, végrehajtható és elvethető. Az elvetett metódusok a szemétgyűjtéshez érhetők el.

(Öröklődés forrása MethodBase)
IsConstructor

Egy értéket kap, amely jelzi, hogy a metódus konstruktor-e.

(Öröklődés forrása MethodBase)
IsFamily

Egy értéket kap, amely jelzi, hogy a metódus vagy a konstruktor láthatóságát a rendszer leírja-e Family; vagyis a metódus vagy a konstruktor csak az osztályán belül és a származtatott osztályokban látható.

(Öröklődés forrása MethodBase)
IsFamilyAndAssembly

Olyan értéket kap, amely jelzi, hogy a metódus vagy a konstruktor láthatóságát a rendszer leírja-e FamANDAssem; vagyis a metódust vagy a konstruktort származtatott osztályok hívhatják meg, de csak akkor, ha ugyanabban a szerelvényben vannak.

(Öröklődés forrása MethodBase)
IsFamilyOrAssembly

Egy értéket kap, amely jelzi, hogy a metódus vagy konstruktor lehetséges láthatóságát a rendszer leírja-e FamORAssem; vagyis a metódust vagy konstruktort származtatott osztályok hívhatják meg, bárhol is vannak, és az ugyanabban a szerelvényben lévő osztályok szerint.

(Öröklődés forrása MethodBase)
IsFinal

Egy értéket kap, amely jelzi, hogy ez a metódus .final

(Öröklődés forrása MethodBase)
IsGenericMethod

Egy értéket kap, amely jelzi, hogy az aktuális metódus általános metódus-e.

(Öröklődés forrása MethodInfo)
IsGenericMethodDefinition

Egy értéket kap, amely jelzi, hogy az aktuális MethodInfo érték egy általános metódus definícióját jelöli-e.

(Öröklődés forrása MethodInfo)
IsHideBySig

Egy értéket kap, amely azt jelzi, hogy csak egy azonos típusú, pontosan azonos aláírással rendelkező tag van-e elrejtve a származtatott osztályban.

(Öröklődés forrása MethodBase)
IsPrivate

Beolvas egy értéket, amely jelzi, hogy ez a tag privát-e.

(Öröklődés forrása MethodBase)
IsPublic

Beolvas egy értéket, amely jelzi, hogy ez nyilvános metódus-e.

(Öröklődés forrása MethodBase)
IsSecurityCritical

Olyan értéket kap, amely jelzi, hogy az aktuális dinamikus módszer biztonsági szempontból kritikus vagy biztonságos-kritikus, ezért kritikus műveleteket hajthat végre.

IsSecurityCritical

Olyan értéket kap, amely jelzi, hogy az aktuális metódus vagy konstruktor biztonsági szempontból kritikus vagy biztonsági szempontból biztonságos-kritikus a jelenlegi megbízhatósági szinten, ezért kritikus műveleteket hajthat végre.

(Öröklődés forrása MethodBase)
IsSecuritySafeCritical

Olyan értéket kap, amely jelzi, hogy az aktuális dinamikus módszer biztonsági szempontból biztonságos-e az aktuális megbízhatósági szinten; vagyis hogy képes-e kritikus műveleteket végrehajtani, és transzparens kóddal elérhető-e.

IsSecuritySafeCritical

Olyan értéket kap, amely jelzi, hogy az aktuális metódus vagy konstruktor biztonsági szempontból biztonságos-e az aktuális megbízhatósági szinten; vagyis hogy képes-e kritikus műveleteket végrehajtani, és transzparens kóddal elérhető-e.

(Öröklődés forrása MethodBase)
IsSecurityTransparent

Olyan értéket kap, amely jelzi, hogy az aktuális dinamikus módszer transzparens-e az aktuális megbízhatósági szinten, ezért nem hajthat végre kritikus műveleteket.

IsSecurityTransparent

Olyan értéket kap, amely jelzi, hogy az aktuális metódus vagy konstruktor transzparens-e az aktuális megbízhatósági szinten, ezért nem hajthat végre kritikus műveleteket.

(Öröklődés forrása MethodBase)
IsSpecialName

Egy értéket kap, amely jelzi, hogy a metódusnak van-e különleges neve.

(Öröklődés forrása MethodBase)
IsStatic

Egy értéket kap, amely jelzi, hogy a metódus .static

(Öröklődés forrása MethodBase)
IsVirtual

Egy értéket kap, amely jelzi, hogy a metódus .virtual

(Öröklődés forrása MethodBase)
MemberType

MemberTypes Egy olyan értéket kap, amely azt jelzi, hogy ez a tag egy metódus.

(Öröklődés forrása MethodInfo)
MetadataToken

Egy metaadat-elemet azonosító értéket kap.

(Öröklődés forrása MemberInfo)
MethodHandle

A dinamikus metódusok nem támogatottak.

MethodImplementationFlags

Lekéri a MethodImplAttributes metódus-implementáció attribútumait meghatározó jelzőket.

(Öröklődés forrása MethodBase)
Module

Lekéri azt a modult, amelyhez a dinamikus metódus logikailag van társítva.

Module

Lekéri azt a modult, amelyben az aktuális MemberInfo által képviselt tagot deklaráló típus van definiálva.

(Öröklődés forrása MemberInfo)
Name

Lekéri a dinamikus metódus nevét.

ReflectedType

Lekéri a metódus beszerzéséhez a tükröződés során használt osztályt.

ReturnParameter

Lekéri a dinamikus metódus visszatérési paraméterét.

ReturnType

Lekéri a dinamikus metódus visszatérési értékének típusát.

ReturnTypeCustomAttributes

Lekéri a dinamikus metódus visszatérési típusának egyéni attribútumait.

Metódusok

Name Description
CreateDelegate(Type, Object)

Befejezi a dinamikus metódust, és létrehoz egy delegáltat, amely a végrehajtáshoz használható, megadva a delegált típusát és egy objektumot, amelyhez a meghatalmazott hozzá van kötve.

CreateDelegate(Type)

Befejezi a dinamikus metódust, és létrehoz egy delegáltat, amely a végrehajtáshoz használható.

DefineParameter(Int32, ParameterAttributes, String)

A dinamikus metódus paraméterét határozza meg.

Equals(Object)

Olyan értéket ad vissza, amely jelzi, hogy ez a példány egyenlő-e egy adott objektummal.

(Öröklődés forrása MethodInfo)
GetBaseDefinition()

A metódus alap implementációjának értékét adja vissza.

GetCustomAttributes(Boolean)

A metódushoz definiált összes egyéni attribútumot adja vissza.

GetCustomAttributes(Type, Boolean)

A metódusra alkalmazott megadott típusú egyéni attribútumokat adja vissza.

GetCustomAttributesData()

Visszaadja a CustomAttributeData céltagra alkalmazott attribútumok adatait képviselő objektumok listáját.

(Öröklődés forrása MemberInfo)
GetDynamicILInfo()

Egy DynamicILInfo objektumot ad vissza, amely metaadat-jogkivonatokból, hatókörökből és Microsoft köztes nyelvi (MSIL-) adatfolyamokból hozhat létre metódustörzset.

GetGenericArguments()

Egy általános metódus típusargumentumait vagy egy általános metódusdefiníció típusparamétereit képviselő objektumtömböt Type ad vissza.

(Öröklődés forrása MethodInfo)
GetGenericMethodDefinition()

Olyan objektumot MethodInfo ad vissza, amely egy általános metódusdefiníciót jelöl, amelyből az aktuális metódus felépíthető.

(Öröklődés forrása MethodInfo)
GetHashCode()

A példány kivonatkódját adja vissza.

(Öröklődés forrása MethodInfo)
GetILGenerator()

Egy Microsoft köztes nyelv (MSIL) generátort ad vissza a metódushoz, amelynek alapértelmezett MSIL-streammérete 64 bájt.

GetILGenerator(Int32)

Egy Microsoft köztes nyelv (MSIL) generátort ad vissza a metódushoz a megadott MSIL-streammérettel.

GetMethodBody()

Ha egy származtatott osztályban felül van bírálva, egy MethodBody objektumot kap, amely hozzáférést biztosít az MSIL-adatfolyamhoz, a helyi változókhoz és az aktuális metódus kivételeihez.

(Öröklődés forrása MethodBase)
GetMethodImplementationFlags()

A metódus implementálási jelzőit adja vissza.

GetParameters()

A dinamikus metódus paramétereit adja vissza.

HasSameMetadataDefinitionAs(MemberInfo)

Olyan dinamikus metódust definiál és jelöl, amely lefordítható, végrehajtható és elvethető. Az elvetett metódusok a szemétgyűjtéshez érhetők el.

(Öröklődés forrása MemberInfo)
Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

Meghívja a dinamikus metódust a megadott paraméterekkel, a megadott kötés megkötései mellett, a megadott kulturális adatokkal.

IsDefined(Type, Boolean)

Azt jelzi, hogy a megadott egyéni attribútumtípus definiálva van-e.

MakeGenericMethod(Type[])

Az aktuális általános metódusdefiníció típusparamétereinek egy típusok tömbjének elemeit helyettesíti, és visszaad egy MethodInfo objektumot, amely az eredményül kapott létrehozott metódust képviseli.

(Öröklődés forrása MethodInfo)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
ToString()

A metódus sztringként ábrázolt aláírását adja vissza.

Explicit interfész-implementációk

Name Description
_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Névkészletet képez le a küldési azonosítók megfelelő készletére.

(Öröklődés forrása MemberInfo)
_MemberInfo.GetType()

Type Lekéri az MemberInfo osztályt jelképező objektumot.

(Öröklődés forrása MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

Lekéri egy objektum típusadatait, amelyek aztán a felület típusadatainak lekérésére használhatók.

(Öröklődés forrása MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1).

(Öröklődés forrása MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz.

(Öröklődés forrása MemberInfo)
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Névkészletet képez le a küldési azonosítók megfelelő készletére.

(Öröklődés forrása MethodBase)
_MethodBase.GetType()

Ennek a tagnak a leírását lásd GetType(): .

(Öröklődés forrása MethodBase)
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr)

Lekéri egy objektum típusadatait, amelyek aztán a felület típusadatainak lekérésére használhatók.

(Öröklődés forrása MethodBase)
_MethodBase.GetTypeInfoCount(UInt32)

Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1).

(Öröklődés forrása MethodBase)
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz.

(Öröklődés forrása MethodBase)
_MethodBase.IsAbstract

Ennek a tagnak a leírását lásd IsAbstract: .

(Öröklődés forrása MethodBase)
_MethodBase.IsAssembly

Ennek a tagnak a leírását lásd IsAssembly: .

(Öröklődés forrása MethodBase)
_MethodBase.IsConstructor

Ennek a tagnak a leírását lásd IsConstructor: .

(Öröklődés forrása MethodBase)
_MethodBase.IsFamily

Ennek a tagnak a leírását lásd IsFamily: .

(Öröklődés forrása MethodBase)
_MethodBase.IsFamilyAndAssembly

Ennek a tagnak a leírását lásd IsFamilyAndAssembly: .

(Öröklődés forrása MethodBase)
_MethodBase.IsFamilyOrAssembly

Ennek a tagnak a leírását lásd IsFamilyOrAssembly: .

(Öröklődés forrása MethodBase)
_MethodBase.IsFinal

Ennek a tagnak a leírását lásd IsFinal: .

(Öröklődés forrása MethodBase)
_MethodBase.IsHideBySig

Ennek a tagnak a leírását lásd IsHideBySig: .

(Öröklődés forrása MethodBase)
_MethodBase.IsPrivate

Ennek a tagnak a leírását lásd IsPrivate: .

(Öröklődés forrása MethodBase)
_MethodBase.IsPublic

Ennek a tagnak a leírását lásd IsPublic: .

(Öröklődés forrása MethodBase)
_MethodBase.IsSpecialName

Ennek a tagnak a leírását lásd IsSpecialName: .

(Öröklődés forrása MethodBase)
_MethodBase.IsStatic

Ennek a tagnak a leírását lásd IsStatic: .

(Öröklődés forrása MethodBase)
_MethodBase.IsVirtual

Ennek a tagnak a leírását lásd IsVirtual: .

(Öröklődés forrása MethodBase)
_MethodInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Névkészletet képez le a küldési azonosítók megfelelő készletére.

(Öröklődés forrása MethodInfo)
_MethodInfo.GetType()

Hozzáférést biztosít a módszerhez a GetType() COM-tól.

(Öröklődés forrása MethodInfo)
_MethodInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

Lekéri egy objektum típusadatait, amelyek a felület típusadatainak lekérésére használhatók.

(Öröklődés forrása MethodInfo)
_MethodInfo.GetTypeInfoCount(UInt32)

Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1).

(Öröklődés forrása MethodInfo)
_MethodInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz.

(Öröklődés forrása MethodInfo)

Bővítő metódusok

Name Description
GetCustomAttribute(MemberInfo, Type, Boolean)

Lekéri a megadott típusú egyéni attribútumot, amely egy adott tagra lesz alkalmazva, és opcionálisan az adott tag elődeit vizsgálja meg.

GetCustomAttribute(MemberInfo, Type)

Egy megadott típusú egyéni attribútumot kér le, amelyet egy adott tagra alkalmaz.

GetCustomAttribute<T>(MemberInfo, Boolean)

Lekéri a megadott típusú egyéni attribútumot, amely egy adott tagra lesz alkalmazva, és opcionálisan az adott tag elődeit vizsgálja meg.

GetCustomAttribute<T>(MemberInfo)

Egy megadott típusú egyéni attribútumot kér le, amelyet egy adott tagra alkalmaz.

GetCustomAttributes(MemberInfo, Boolean)

Lekéri a megadott tagra alkalmazott egyéni attribútumok gyűjteményét, és opcionálisan az adott tag őseit vizsgálja meg.

GetCustomAttributes(MemberInfo, Type, Boolean)

Lekéri a megadott típusú egyéni attribútumok gyűjteményét, amelyek egy adott tagra vonatkoznak, és opcionálisan az adott tag elődeit is érintik.

GetCustomAttributes(MemberInfo, Type)

Egy megadott típusú egyéni attribútumok gyűjteményét kéri le, amelyeket egy adott tagra alkalmaz.

GetCustomAttributes(MemberInfo)

Egy adott tagra alkalmazott egyéni attribútumok gyűjteményét kéri le.

GetCustomAttributes<T>(MemberInfo, Boolean)

Lekéri a megadott típusú egyéni attribútumok gyűjteményét, amelyek egy adott tagra vonatkoznak, és opcionálisan az adott tag elődeit is érintik.

GetCustomAttributes<T>(MemberInfo)

Egy megadott típusú egyéni attribútumok gyűjteményét kéri le, amelyeket egy adott tagra alkalmaz.

GetRuntimeBaseDefinition(MethodInfo)

Egy objektumot kér le, amely a megadott metódust jelöli azon a közvetlen vagy közvetett alaposztályon, ahol a metódus először deklarálva lett.

IsDefined(MemberInfo, Type, Boolean)

Azt jelzi, hogy a megadott típusú egyéni attribútumok alkalmazhatók-e egy adott tagra, és szükség esetén alkalmazva vannak-e az elődökre.

IsDefined(MemberInfo, Type)

Azt jelzi, hogy a megadott típusú egyéni attribútumok alkalmazhatók-e egy adott tagra.

A következőre érvényes:

Lásd még