MethodBuilder Classe

Definizione

Definisce e rappresenta un metodo (o costruttore) di una classe dinamica.

public ref class MethodBuilder sealed : System::Reflection::MethodInfo
public ref class MethodBuilder abstract : System::Reflection::MethodInfo
public ref class MethodBuilder sealed : System::Reflection::MethodInfo, System::Runtime::InteropServices::_MethodBuilder
public sealed class MethodBuilder : System.Reflection.MethodInfo
public abstract class MethodBuilder : System.Reflection.MethodInfo
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class MethodBuilder : System.Reflection.MethodInfo, System.Runtime.InteropServices._MethodBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class MethodBuilder : System.Reflection.MethodInfo, System.Runtime.InteropServices._MethodBuilder
type MethodBuilder = class
    inherit MethodInfo
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type MethodBuilder = class
    inherit MethodInfo
    interface _MethodBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MethodBuilder = class
    inherit MethodInfo
    interface _MethodBuilder
Public NotInheritable Class MethodBuilder
Inherits MethodInfo
Public MustInherit Class MethodBuilder
Inherits MethodInfo
Public NotInheritable Class MethodBuilder
Inherits MethodInfo
Implements _MethodBuilder
Ereditarietà
Attributi
Implementazioni

Esempio

Nell'esempio seguente viene usata la MethodBuilder classe per creare un metodo all'interno di un tipo dinamico.

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;

void AddMethodDynamically( TypeBuilder^ myTypeBld, 
                           String^ mthdName, 
                           array<Type^>^ mthdParams, 
                           Type^ returnType, 
                           String^ mthdAction )
{
   MethodBuilder^ myMthdBld = myTypeBld->DefineMethod( mthdName, static_cast<MethodAttributes>(MethodAttributes::Public | MethodAttributes::Static), returnType, mthdParams );
   ILGenerator^ ILOut = myMthdBld->GetILGenerator();
   int numParams = mthdParams->Length;
   for ( Byte x = 0; x < numParams; x++ )
   {
      ILOut->Emit( OpCodes::Ldarg_S, x );

   }
   if ( numParams > 1 )
   {
      for ( int y = 0; y < (numParams - 1); y++ )
      {
         if ( mthdAction->Equals( "A" ) )
                  ILOut->Emit( OpCodes::Add );
         else
         if ( mthdAction->Equals( "M" ) )
                  ILOut->Emit( OpCodes::Mul );
         else
                  ILOut->Emit( OpCodes::Add );

      }
   }

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

void main()
{
   AppDomain^ myDomain = AppDomain::CurrentDomain;
   AssemblyName^ asmName = gcnew AssemblyName;
   asmName->Name = "MyDynamicAsm";
   AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( asmName, 
                                                                    AssemblyBuilderAccess::RunAndSave );
   ModuleBuilder^ myModule = myAsmBuilder->DefineDynamicModule( "MyDynamicAsm", 
                                                                "MyDynamicAsm.dll" );
   TypeBuilder^ myTypeBld = myModule->DefineType( "MyDynamicType", 
                                                  TypeAttributes::Public );
   
   // Get info from the user to build the method dynamically.
   Console::WriteLine( "Let's build a simple method dynamically!" );
   Console::WriteLine( "Please enter a few numbers, separated by spaces." );
   String^ inputNums = Console::ReadLine();
   Console::Write( "Do you want to [A]dd (default) or [M]ultiply these numbers? " );
   String^ myMthdAction = Console::ReadLine()->ToUpper();
   Console::Write( "Lastly, what do you want to name your new dynamic method? " );
   String^ myMthdName = Console::ReadLine();
   
   // Process inputNums into an array and create a corresponding Type array
   int index = 0;
   array<String^>^inputNumsList = inputNums->Split();
   array<Type^>^myMthdParams = gcnew array<Type^>(inputNumsList->Length);
   array<Object^>^inputValsList = gcnew array<Object^>(inputNumsList->Length);
   for each (String^ inputNum in inputNumsList)
   {
      inputValsList[ index ] = Convert::ToInt32( inputNum );
      myMthdParams[ index ] = int::typeid;
      index++;
   }

   
   // Now, call the method building method with the parameters, passing the
   // TypeBuilder by reference.
   AddMethodDynamically( myTypeBld, 
                         myMthdName, 
                         myMthdParams, 
                         int::typeid, 
                         myMthdAction );
   Type^ myType = myTypeBld->CreateType();

   Console::WriteLine( "---" );
   Console::WriteLine( "The result of {0} the inputted values is: {1}", 
                       ((myMthdAction->Equals( "M" )) ? "multiplying" : "adding"), 
                       myType->InvokeMember( myMthdName, 
                                             BindingFlags::InvokeMethod | BindingFlags::Public | BindingFlags::Static, 
                       nullptr, 
                       nullptr, 
                       inputValsList ) );
   Console::WriteLine( "---" );
   
   // Let's take a look at the method we created.
   // If you are interested in seeing the MSIL generated dynamically for the method
   // your program generated, change to the directory where you ran the compiled
   // code sample and type "ildasm MyDynamicAsm.dll" at the prompt. When the list
   // of manifest contents appears, click on "MyDynamicType" and then on the name of
   // of the method you provided during execution.

   myAsmBuilder->Save( "MyDynamicAsm.dll" );

   MethodInfo^ myMthdInfo = myType->GetMethod( myMthdName );
   Console::WriteLine( "Your Dynamic Method: {0};", myMthdInfo );
}

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

class DemoMethodBuilder
{
    public static void AddMethodDynamically (TypeBuilder myTypeBld,
                                             string mthdName,
                                             Type[] mthdParams,
                                             Type returnType,
                                             string mthdAction)
    {

        MethodBuilder myMthdBld = myTypeBld.DefineMethod(
                                             mthdName,
                                             MethodAttributes.Public |
                                             MethodAttributes.Static,
                                             returnType,
                                             mthdParams);

        ILGenerator ILout = myMthdBld.GetILGenerator();

        int numParams = mthdParams.Length;

        for (byte x=0; x < numParams; x++)
        {
            ILout.Emit(OpCodes.Ldarg_S, x);
        }

        if (numParams > 1)
        {
            for (int y=0; y<(numParams-1); y++)
            {
                switch (mthdAction)
                {
                    case "A": ILout.Emit(OpCodes.Add);
                              break;
                    case "M": ILout.Emit(OpCodes.Mul);
                              break;
                    default: ILout.Emit(OpCodes.Add);
                              break;
                }
            }
        }
        ILout.Emit(OpCodes.Ret);
    }

    public static void Main()
    {
        AppDomain myDomain = AppDomain.CurrentDomain;
        AssemblyName asmName = new AssemblyName();
        asmName.Name = "MyDynamicAsm";

        AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
                                       asmName,
                                       AssemblyBuilderAccess.RunAndSave);

        ModuleBuilder myModule = myAsmBuilder.DefineDynamicModule("MyDynamicAsm",
                                                                  "MyDynamicAsm.dll");

        TypeBuilder myTypeBld = myModule.DefineType("MyDynamicType",
                                                    TypeAttributes.Public);

        // Get info from the user to build the method dynamically.
        Console.WriteLine("Let's build a simple method dynamically!");
        Console.WriteLine("Please enter a few numbers, separated by spaces.");
        string inputNums = Console.ReadLine();
        Console.Write("Do you want to [A]dd (default) or [M]ultiply these numbers? ");
        string myMthdAction = Console.ReadLine().ToUpper();
        Console.Write("Lastly, what do you want to name your new dynamic method? ");
        string myMthdName = Console.ReadLine();

        // Process inputNums into an array and create a corresponding Type array
        int index = 0;
        string[] inputNumsList = inputNums.Split();

        Type[] myMthdParams = new Type[inputNumsList.Length];
        object[] inputValsList = new object[inputNumsList.Length];

        foreach (string inputNum in inputNumsList)
        {
            inputValsList[index] = (object)Convert.ToInt32(inputNum);
                myMthdParams[index] = typeof(int);
                index++;
        }

        // Now, call the method building method with the parameters, passing the
        // TypeBuilder by reference.
        AddMethodDynamically(myTypeBld,
                             myMthdName,
                             myMthdParams,
                             typeof(int),
                             myMthdAction);

        Type myType = myTypeBld.CreateType();

        Console.WriteLine("---");
        Console.WriteLine("The result of {0} the inputted values is: {1}",
                          ((myMthdAction == "M") ? "multiplying" : "adding"),
                          myType.InvokeMember(myMthdName,
                          BindingFlags.InvokeMethod | BindingFlags.Public |
                          BindingFlags.Static,
                          null,
                          null,
                          inputValsList));
        Console.WriteLine("---");

        // Let's take a look at the method we created.
        // If you are interested in seeing the MSIL generated dynamically for the method
        // your program generated, change to the directory where you ran the compiled
        // code sample and type "ildasm MyDynamicAsm.dll" at the prompt. When the list
        // of manifest contents appears, click on "MyDynamicType" and then on the name of
        // of the method you provided during execution.

        myAsmBuilder.Save("MyDynamicAsm.dll");

        MethodInfo myMthdInfo = myType.GetMethod(myMthdName);
        Console.WriteLine("Your Dynamic Method: {0};", myMthdInfo.ToString());
    }
}
Imports System.Reflection
Imports System.Reflection.Emit

Class DemoMethodBuilder
   
   Public Shared Sub AddMethodDynamically(ByVal myTypeBld As TypeBuilder, _
                                          ByVal mthdName As String, _
                                          ByVal mthdParams() As Type, _
                                          ByVal returnType As Type, _
                                          ByVal mthdAction As String)
      
      Dim myMthdBld As MethodBuilder = myTypeBld.DefineMethod(mthdName, _
                                       MethodAttributes.Public Or MethodAttributes.Static, _
                                       returnType, _
                                       mthdParams)
      
      Dim ILout As ILGenerator = myMthdBld.GetILGenerator()
      
      Dim numParams As Integer = mthdParams.Length
      
      Dim x As Byte
      For x = 0 To numParams - 1
         ILout.Emit(OpCodes.Ldarg_S, x)
      Next x
      
      If numParams > 1 Then
         Dim y As Integer
         For y = 0 To (numParams - 1) - 1
            Select Case mthdAction
               Case "A"
                  ILout.Emit(OpCodes.Add)
               Case "M"
                  ILout.Emit(OpCodes.Mul)
               Case Else
                  ILout.Emit(OpCodes.Add)
            End Select
         Next y
      End If
      ILout.Emit(OpCodes.Ret)
   End Sub 
    
   
   Public Shared Sub Main()
      
      Dim myDomain As AppDomain = AppDomain.CurrentDomain
      Dim asmName As New AssemblyName()
      asmName.Name = "MyDynamicAsm"
      
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(asmName, _
                                            AssemblyBuilderAccess.RunAndSave)
      
      Dim myModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule("MyDynamicAsm", _
                                                                       "MyDynamicAsm.dll")
      
      Dim myTypeBld As TypeBuilder = myModule.DefineType("MyDynamicType", TypeAttributes.Public)
      
      ' Get info from the user to build the method dynamically.
      Console.WriteLine("Let's build a simple method dynamically!")
      Console.WriteLine("Please enter a few numbers, separated by spaces.")
      Dim inputNums As String = Console.ReadLine()
      Console.Write("Do you want to [A]dd (default) or [M]ultiply these numbers? ")
      Dim myMthdAction As String = Console.ReadLine().ToUpper()
      Console.Write("Lastly, what do you want to name your new dynamic method? ")
      Dim myMthdName As String = Console.ReadLine()
      
      ' Process inputNums into an array and create a corresponding Type array 
      Dim index As Integer = 0
      Dim inputNumsList As String() = inputNums.Split()
      
      Dim myMthdParams(inputNumsList.Length - 1) As Type
      Dim inputValsList(inputNumsList.Length - 1) As Object
      
      
      Dim inputNum As String
      For Each inputNum In  inputNumsList
         inputValsList(index) = CType(Convert.ToInt32(inputNum), Object)
         myMthdParams(index) = GetType(Integer)
         index += 1
      Next inputNum
      
      ' Now, call the method building method with the parameters, passing the 
      ' TypeBuilder by reference.
      AddMethodDynamically(myTypeBld, myMthdName, myMthdParams, GetType(Integer), myMthdAction)
      
      Dim myType As Type = myTypeBld.CreateType()
     
      Dim description as String 
      If myMthdAction = "M" Then
         description = "multiplying"
      Else
         description = "adding"
      End If

      Console.WriteLine("---")
      Console.WriteLine("The result of {0} the values is: {1}", _
                         description, _
                         myType.InvokeMember(myMthdName, _
                                             BindingFlags.InvokeMethod _
                                               Or BindingFlags.Public _
                                               Or BindingFlags.Static, _
                                             Nothing, _
                                             Nothing, _
                                             inputValsList)) 
      Console.WriteLine("---")

      ' If you are interested in seeing the MSIL generated dynamically for the method
      ' your program generated, change to the directory where you ran the compiled
      ' code sample and type "ildasm MyDynamicAsm.dll" at the prompt. When the list
      ' of manifest contents appears, click on "MyDynamicType" and then on the name of
      ' of the method you provided during execution.
 
      myAsmBuilder.Save("MyDynamicAsm.dll") 

      Dim myMthdInfo As MethodInfo = myType.GetMethod(myMthdName)
      Console.WriteLine("Your Dynamic Method: {0};", myMthdInfo.ToString())
   End Sub 
End Class

Commenti

Per altre informazioni su questa API, vedere Osservazioni api supplementari per MethodBuilder.

Costruttori

MethodBuilder()

Inizializza una nuova istanza della classe MethodBuilder.

Proprietà

Attributes

Recupera gli attributi per questo metodo.

CallingConvention

Restituisce la convenzione di chiamata del metodo.

ContainsGenericParameters

Non supportato per questo tipo.

ContainsGenericParameters

Ottiene un valore che indica se un metodo generico contiene parametri di tipo generico non assegnati.

(Ereditato da MethodInfo)
CustomAttributes

Ottiene una raccolta che contiene gli attributi personalizzati del membro.

(Ereditato da MemberInfo)
DeclaringType

Restituisce il tipo che dichiara il metodo.

InitLocals

Ottiene o imposta un valore booleano che specifica se le variabili locali in questo metodo sono inizializzate su zero. Il valore predefinito di questa proprietà è true.

InitLocalsCore

In caso di override in una classe derivata, ottiene o imposta un valore che indica se le variabili locali in questo metodo sono inizializzate zero.

IsAbstract

Ottiene un valore che indica se il metodo è astratto.

(Ereditato da MethodBase)
IsAssembly

Ottiene un valore che indica se la visibilità potenziale di questo metodo o costruttore è descritta da Assembly, ovvero se il metodo o costruttore è visibile al massimo ad altri tipi dello stesso assembly, ma non ai tipi derivati all'esterno dell'assembly.

(Ereditato da MethodBase)
IsCollectible

Ottiene un valore che indica se questo oggetto MemberInfo fa parte di un assembly conservato in un AssemblyLoadContext ritirabile.

(Ereditato da MemberInfo)
IsConstructedGenericMethod

Definisce e rappresenta un metodo (o costruttore) di una classe dinamica.

IsConstructedGenericMethod

Definisce e rappresenta un metodo (o costruttore) di una classe dinamica.

(Ereditato da MethodBase)
IsConstructor

Ottiene un valore che indica se il metodo è un costruttore.

(Ereditato da MethodBase)
IsFamily

Ottiene un valore che indica se la visibilità di questo metodo o costruttore è descritta da Family, ovvero se il metodo o costruttore è visibile solo all'interno della relativa classe e delle classi derivate.

(Ereditato da MethodBase)
IsFamilyAndAssembly

Ottiene un valore che indica se la visibilità di questo metodo o costruttore è descritta da FamANDAssem, ovvero se è possibile chiamare il metodo o il costruttore da classi derivate, ma solo se appartenenti allo stesso assembly.

(Ereditato da MethodBase)
IsFamilyOrAssembly

Ottiene un valore che indica se la visibilità potenziale di questo metodo o costruttore è descritta da FamORAssem, ovvero se è possibile chiamare il metodo o il costruttore da classi derivate indipendentemente dalla posizione e da classi appartenenti allo stesso assembly.

(Ereditato da MethodBase)
IsFinal

Ottiene un valore che indica se il metodo è final.

(Ereditato da MethodBase)
IsGenericMethod

Ottiene un valore che indica se il metodo è un metodo generico.

IsGenericMethod

Ottiene un valore che indica se il metodo corrente è un metodo generico.

(Ereditato da MethodInfo)
IsGenericMethodDefinition

Ottiene un valore che indica se l'oggetto MethodBuilder corrente rappresenta la definizione di un metodo generico.

IsGenericMethodDefinition

Ottiene un valore che indica se la classe MethodInfo corrente rappresenta la definizione di un metodo generico.

(Ereditato da MethodInfo)
IsHideBySig

Ottiene un valore che indica se nella classe derivata è nascosto un solo membro dello stesso tipo che riporta esattamente la stessa firma.

(Ereditato da MethodBase)
IsPrivate

Ottiene un valore che indica se questo membro è privato.

(Ereditato da MethodBase)
IsPublic

Ottiene un valore che indica se si tratta di un metodo pubblico.

(Ereditato da MethodBase)
IsSecurityCritical

Genera un'eccezione NotSupportedException in tutti i casi.

IsSecurityCritical

Ottiene un valore che indica se il metodo o il costruttore corrente è critico per la sicurezza o security-safe-critical al livello di attendibilità corrente, e pertanto può eseguire operazioni critiche.

(Ereditato da MethodBase)
IsSecuritySafeCritical

Genera un'eccezione NotSupportedException in tutti i casi.

IsSecuritySafeCritical

Ottiene un valore che indica se il metodo o il costruttore corrente è security-safe-critical al livello di attendibilità corrente, vale a dire se può eseguire operazioni critiche ed essere richiamato da codice trasparente.

(Ereditato da MethodBase)
IsSecurityTransparent

Genera un'eccezione NotSupportedException in tutti i casi.

IsSecurityTransparent

Ottiene un valore che indica se il metodo o il costruttore corrente è trasparente al livello di attendibilità corrente, e pertanto non può eseguire operazioni critiche.

(Ereditato da MethodBase)
IsSpecialName

Ottiene un valore che indica se questo metodo ha un nome speciale.

(Ereditato da MethodBase)
IsStatic

Ottiene un valore che indica se il metodo è static.

(Ereditato da MethodBase)
IsVirtual

Ottiene un valore che indica se il metodo è virtual.

(Ereditato da MethodBase)
MemberType

Ottiene un valore MemberTypes che indica che questo membro è un metodo.

(Ereditato da MethodInfo)
MetadataToken

Ottiene un token che identifica il modulo dinamico corrente nei metadati.

MetadataToken

Ottiene un valore che identifica un elemento di metadati.

(Ereditato da MemberInfo)
MethodHandle

Recupera l'handle interno per il metodo. Questo handle consente di accedere all'handle dei metadati sottostanti.

MethodHandle

Ottiene un handle alla rappresentazione interna dei metadati di un metodo.

(Ereditato da MethodBase)
MethodImplementationFlags

Definisce e rappresenta un metodo (o costruttore) di una classe dinamica.

MethodImplementationFlags

Ottiene i flag MethodImplAttributes che specificano gli attributi di implementazione di un metodo.

(Ereditato da MethodBase)
Module

Ottiene il modulo in cui è definito il metodo corrente.

Module

Ottiene il modulo in cui viene definito il tipo che dichiara il membro rappresentato dall'oggetto MemberInfo corrente.

(Ereditato da MemberInfo)
Name

Recupera il nome di questo metodo.

ReflectedType

Recupera la classe usata nella reflection per ottenere l'oggetto.

ReflectedType

Ottiene l'oggetto classe utilizzato per ottenere questa istanza di MemberInfo.

(Ereditato da MemberInfo)
ReturnParameter

Ottiene un oggetto ParameterInfo contenente informazioni sul tipo restituito dal metodo, ad esempio se il tipo restituito contiene modificatori personalizzati.

ReturnParameter

Ottiene un oggetto ParameterInfo contenente informazioni sul tipo restituito dal metodo, ad esempio se il tipo restituito contiene modificatori personalizzati.

(Ereditato da MethodInfo)
ReturnType

Ottiene il tipo restituito del metodo rappresentato da questo oggetto MethodBuilder.

ReturnType

Ottiene il tipo restituito di questo metodo.

(Ereditato da MethodInfo)
ReturnTypeCustomAttributes

Restituisce gli attributi personalizzati del tipo restituito del metodo.

ReturnTypeCustomAttributes

Ottiene gli attributi personalizzati per il tipo restituito.

(Ereditato da MethodInfo)
Signature

Recupera la firma del metodo.

Metodi

AddDeclarativeSecurity(SecurityAction, PermissionSet)

Aggiunge sicurezza dichiarativa a questo metodo.

CreateDelegate(Type)

Crea un delegato del tipo specificato da questo metodo.

(Ereditato da MethodInfo)
CreateDelegate(Type, Object)

Crea un delegato del tipo specificato con la destinazione specificata da questo metodo.

(Ereditato da MethodInfo)
CreateDelegate<T>()

Crea un delegato di tipo T da questo metodo.

(Ereditato da MethodInfo)
CreateDelegate<T>(Object)

Crea un delegato di tipo T con la destinazione specificata da questo metodo.

(Ereditato da MethodInfo)
CreateMethodBody(Byte[], Int32)

Crea il corpo del metodo usando una matrice di byte fornita di istruzioni Microsoft Intermediate Language (MSIL).

DefineGenericParameters(String[])

Imposta il numero dei parametri di tipo generico per il metodo corrente, specificandone i nomi, e restituisce una matrice di oggetti GenericTypeParameterBuilder che possono essere usati per definire i vincoli.

DefineGenericParametersCore(String[])

In caso di override in una classe derivata, imposta il numero di parametri di tipo generico per il metodo corrente, ne specifica i nomi e restituisce una matrice di GenericTypeParameterBuilder oggetti che possono essere utilizzati per definire i relativi vincoli.

DefineParameter(Int32, ParameterAttributes, String)

Imposta gli attributi del parametro e il nome di un parametro di questo metodo oppure del valore restituito di questo metodo. Restituisce un oggetto ParameterBuilder che può essere usato per applicare attributi personalizzati.

DefineParameterCore(Int32, ParameterAttributes, String)

Quando sottoposto a override in una classe derivata, definisce un parametro o un parametro restituito per questo metodo.

Equals(Object)

Determina se l'oggetto specificato è uguale a questa istanza.

GetBaseDefinition()

Restituisce l'implementazione di base per un metodo.

GetBaseDefinition()

Quando ne viene eseguito l'override in una classe derivata,, restituisce l'oggetto MethodInfo relativo al metodo presente nella classe base diretta o indiretta in cui il metodo rappresentato da questa istanza è stato inizialmente dichiarato.

(Ereditato da MethodInfo)
GetCustomAttributes(Boolean)

Restituisce tutti gli attributi personalizzati definiti per questo metodo.

GetCustomAttributes(Boolean)

Se sottoposto a override in una classe derivata, restituisce una matrice di tutti gli attributi personalizzati applicati a questo membro.

(Ereditato da MemberInfo)
GetCustomAttributes(Type, Boolean)

Restituisce gli attributi personalizzati identificati dal tipo specificato.

GetCustomAttributes(Type, Boolean)

Quando viene sottoposto a override in una classe derivata, questo metodo restituisce una matrice di attributi personalizzati applicati a questo membro e identificati da Type.

(Ereditato da MemberInfo)
GetCustomAttributesData()

Restituisce un elenco di oggetti CustomAttributeData che rappresentano i dati relativi agli attributi applicati al membro di destinazione.

(Ereditato da MemberInfo)
GetGenericArguments()

Restituisce una matrice di oggetti GenericTypeParameterBuilder che rappresentano i parametri di tipo del metodo, se è generico.

GetGenericArguments()

Restituisce una matrice di oggetti Type che rappresentano gli argomenti tipo di un metodo generico o i parametri di tipo della definizione di un metodo generico.

(Ereditato da MethodInfo)
GetGenericMethodDefinition()

Restituisce questo metodo.

GetGenericMethodDefinition()

Restituisce un oggetto MethodInfo che rappresenta la definizione di un metodo generica da cui è possibile costruire il metodo corrente.

(Ereditato da MethodInfo)
GetHashCode()

Ottiene il codice hash per questo metodo.

GetILGenerator()

Restituisce un oggetto ILGenerator per il metodo con una dimensione di flusso MSIL (Microsoft Intermediate Language) predefinita di 64 byte.

GetILGenerator(Int32)

Restituisce un oggetto ILGenerator per il metodo con le dimensioni del flusso MSIL (Microsoft Intermediate Language) specificate.

GetILGeneratorCore(Int32)

Quando sottoposto a override in una classe derivata, ottiene un ILGenerator oggetto che può essere utilizzato per generare un corpo del metodo per questo metodo.

GetMethodBody()

Se viene eseguito l'override in una classe derivata, ottiene un oggetto MethodBody che consente di accedere al flusso MSIL, alle variabili locali e alle eccezioni per il metodo corrente.

(Ereditato da MethodBase)
GetMethodImplementationFlags()

Restituisce i flag di implementazione per il metodo.

GetMethodImplementationFlags()

Quando è sottoposto a override in una classe derivata, restituisce i flag MethodImplAttributes.

(Ereditato da MethodBase)
GetModule()

Restituisce un riferimento al modulo che contiene questo metodo.

GetParameters()

Restituisce il parametro del metodo.

GetToken()

Restituisce l'oggetto MethodToken che rappresenta il token per questo metodo.

GetType()

Individua gli attributi di un metodo e consente di accedere ai relativi metadati.

(Ereditato da MethodInfo)
HasSameMetadataDefinitionAs(MemberInfo)

Definisce e rappresenta un metodo (o costruttore) di una classe dinamica.

(Ereditato da MemberInfo)
Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

Richiama dinamicamente il metodo ottenuto mediante reflection da questa istanza sull'oggetto indicato, passando i parametri specificati e con i vincoli del binder indicato.

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

Quando viene sottoposto a override in una classe derivata, richiama il metodo o il costruttore ottenuto mediante reflection con i parametri specificati.

(Ereditato da MethodBase)
Invoke(Object, Object[])

Richiama il metodo o il costruttore rappresentato dall'istanza corrente usando i parametri specificati.

(Ereditato da MethodInfo)
IsDefined(Type, Boolean)

Controlla se il tipo di attributo personalizzato specificato è definito.

IsDefined(Type, Boolean)

Quando se ne effettua l'override in una classe derivata, indica se a questo membro sono applicati uno o più attributi del tipo specificato o dei tipi derivati.

(Ereditato da MemberInfo)
MakeGenericMethod(Type[])

Restituisce un metodo generico costruito dalla definizione di metodo generico corrente usando gli argomenti tipo generico specificati.

MakeGenericMethod(Type[])

Sostituisce con gli elementi di una matrice di tipi i parametri di tipo della definizione di metodo generica corrente e restituisce un oggetto MethodInfo che rappresenta il metodo costruito risultante.

(Ereditato da MethodInfo)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
SetCustomAttribute(ConstructorInfo, Byte[])

Imposta un attributo personalizzato usando un BLOB di attributi personalizzati specificato.

SetCustomAttribute(CustomAttributeBuilder)

Imposta un attributo personalizzato usando un generatore di attributi personalizzati.

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

Quando ne viene eseguito l'override in una classe derivata, imposta un attributo personalizzato su questo assembly.

SetImplementationFlags(MethodImplAttributes)

Imposta i flag di implementazione per il metodo.

SetImplementationFlagsCore(MethodImplAttributes)

Quando sottoposto a override in una classe derivata, imposta i flag di implementazione per questo metodo.

SetMarshal(UnmanagedMarshal)
Obsoleti.

Imposta le informazioni di marshalling per il tipo restituito del metodo.

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

Crea il corpo del metodo usando una matrice di byte specificata di istruzioni Microsoft Intermediate Language (MSIL).

SetParameters(Type[])

Imposta il numero e i tipi di parametri per un metodo.

SetReturnType(Type)

Imposta il tipo restituito del metodo.

SetSignature(Type, Type[], Type[], Type[], Type[][], Type[][])

Imposta la firma del metodo, incluso il tipo restituito, i tipi di parametro e i modificatori personalizzati obbligatori e facoltativi del tipo restituito e dei tipi di parametro.

SetSignatureCore(Type, Type[], Type[], Type[], Type[][], Type[][])

In caso di override in una classe derivata, imposta la firma del metodo, incluso il tipo restituito, i tipi di parametro e i modificatori personalizzati obbligatori e facoltativi dei tipi di parametro e del tipo restituito.

SetSymCustomAttribute(String, Byte[])

Imposta un attributo personalizzato simbolico usando un BLOB.

ToString()

Restituisce questa istanza di MethodBuilder come stringa.

Implementazioni dell'interfaccia esplicita

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

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da MemberInfo)
_MemberInfo.GetType()

Ottiene un oggetto Type che rappresenta la classe MemberInfo.

(Ereditato da MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto che può quindi essere usato per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da MemberInfo)
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da MethodBase)
_MethodBase.GetType()

Per una descrizione di questo membro, vedere GetType().

(Ereditato da MethodBase)
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto che può quindi essere usato per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da MethodBase)
_MethodBase.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da MethodBase)
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da MethodBase)
_MethodBase.IsAbstract

Per una descrizione di questo membro, vedere IsAbstract.

(Ereditato da MethodBase)
_MethodBase.IsAssembly

Per una descrizione di questo membro, vedere IsAssembly.

(Ereditato da MethodBase)
_MethodBase.IsConstructor

Per una descrizione di questo membro, vedere IsConstructor.

(Ereditato da MethodBase)
_MethodBase.IsFamily

Per una descrizione di questo membro, vedere IsFamily.

(Ereditato da MethodBase)
_MethodBase.IsFamilyAndAssembly

Per una descrizione di questo membro, vedere IsFamilyAndAssembly.

(Ereditato da MethodBase)
_MethodBase.IsFamilyOrAssembly

Per una descrizione di questo membro, vedere IsFamilyOrAssembly.

(Ereditato da MethodBase)
_MethodBase.IsFinal

Per una descrizione di questo membro, vedere IsFinal.

(Ereditato da MethodBase)
_MethodBase.IsHideBySig

Per una descrizione di questo membro, vedere IsHideBySig.

(Ereditato da MethodBase)
_MethodBase.IsPrivate

Per una descrizione di questo membro, vedere IsPrivate.

(Ereditato da MethodBase)
_MethodBase.IsPublic

Per una descrizione di questo membro, vedere IsPublic.

(Ereditato da MethodBase)
_MethodBase.IsSpecialName

Per una descrizione di questo membro, vedere IsSpecialName.

(Ereditato da MethodBase)
_MethodBase.IsStatic

Per una descrizione di questo membro, vedere IsStatic.

(Ereditato da MethodBase)
_MethodBase.IsVirtual

Per una descrizione di questo membro, vedere IsVirtual.

(Ereditato da MethodBase)
_MethodBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

_MethodBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto che può quindi essere usato per ottenere informazioni sul tipo relative a un'interfaccia.

_MethodBuilder.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

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

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

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

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da MethodInfo)
_MethodInfo.GetType()

Fornisce l'accesso al metodo GetType() da COM.

(Ereditato da MethodInfo)
_MethodInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da MethodInfo)
_MethodInfo.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da MethodInfo)
_MethodInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da MethodInfo)
ICustomAttributeProvider.GetCustomAttributes(Boolean)

Restituisce una matrice di tutti gli attributi personalizzati definiti in questo membro, esclusi gli attributi denominati, oppure una matrice vuota se non sono presenti attributi personalizzati.

(Ereditato da MemberInfo)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

Restituisce una matrice di attributi personalizzati definiti in questo membro, identificati dal tipo o da una matrice vuota, se non sono presenti attributi personalizzati di quel tipo.

(Ereditato da MemberInfo)
ICustomAttributeProvider.IsDefined(Type, Boolean)

Indica se per questo membro sono definite una o più istanze di attributeType.

(Ereditato da MemberInfo)

Metodi di estensione

GetCustomAttribute(MemberInfo, Type)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un membro specificato.

GetCustomAttribute(MemberInfo, Type, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un membro specificato e verifica facoltativamente i predecessori di tale membro.

GetCustomAttribute<T>(MemberInfo)

Recupera una attributo personalizzato di un tipo specificato che viene applicato a un membro specificato.

GetCustomAttribute<T>(MemberInfo, Boolean)

Recupera un attributo personalizzato di un tipo specificato che viene applicato a un membro specificato e verifica facoltativamente i predecessori di tale membro.

GetCustomAttributes(MemberInfo)

Recupera una raccolta di attributi personalizzati che vengono applicati a un membro specificato.

GetCustomAttributes(MemberInfo, Boolean)

Recupera una raccolta di attributi personalizzati che vengono applicati a un membro specificato e verifica facoltativamente i predecessori di tale membro.

GetCustomAttributes(MemberInfo, Type)

Recupera una raccolta di attributi personalizzati di un tipo specificato che vengono applicati a un membro specificato.

GetCustomAttributes(MemberInfo, Type, Boolean)

Recupera una raccolta di attributi personalizzati di un tipo specificato che vengono applicati a un membro specificato e verifica facoltativamente i predecessori di tale membro.

GetCustomAttributes<T>(MemberInfo)

Recupera una raccolta di attributi personalizzati di un tipo specificato che vengono applicati a un membro specificato.

GetCustomAttributes<T>(MemberInfo, Boolean)

Recupera una raccolta di attributi personalizzati di un tipo specificato che vengono applicati a un membro specificato e verifica facoltativamente i predecessori di tale membro.

IsDefined(MemberInfo, Type)

Indica se vengono applicati attributi personalizzati del tipo specificato a un membro specificato.

IsDefined(MemberInfo, Type, Boolean)

Indica se gli attributi personalizzati di un tipo specificato vengono applicati a un membro specificato e, facoltativamente, ai relativi predecessori.

GetMetadataToken(MemberInfo)

Ottiene un token di metadati per il membro specificato, se disponibile.

HasMetadataToken(MemberInfo)

Restituisce un valore che indica se un token di metadati è disponibile per il membro specificato.

GetBaseDefinition(MethodInfo)

Definisce e rappresenta un metodo (o costruttore) di una classe dinamica.

GetRuntimeBaseDefinition(MethodInfo)

Recupera un oggetto che rappresenta il metodo specificato nella classe di base diretta o indiretta in cui il metodo è stato inizialmente dichiarato.

Si applica a