DynamicMethod Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Define y representa un método dinámico que se puede compilar, ejecutar y descartar. Los métodos descartados están disponibles para la recolección de elementos no utilizados.
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
- Herencia
- Atributos
Ejemplos
En el ejemplo de código siguiente se crea un método dinámico que toma dos parámetros. En el ejemplo se emite un cuerpo de función simple que imprime el primer parámetro en la consola y el ejemplo usa el segundo parámetro como valor devuelto del método. En el ejemplo se completa el método mediante la creación de un delegado, se invoca al delegado con parámetros diferentes y, por último, se invoca el método dinámico mediante el Invoke método .
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
Comentarios
Para obtener más información sobre esta API, consulte Comentarios complementarios de API para DynamicMethod.
Constructores
| Nombre | Description |
|---|---|
| DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean) |
Crea un método dinámico global para un módulo, especificando el nombre del método, los atributos, la convención de llamada, el tipo de valor devuelto, los tipos de parámetros, el módulo y si las comprobaciones de visibilidad Just-In-Time (JIT) deben omitirse para los tipos y miembros a los que accede el lenguaje intermedio (MSIL) de Microsoft del método dinámico. |
| DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type, Boolean) |
Crea un método dinámico, especificando el nombre del método, los atributos, la convención de llamada, el tipo de valor devuelto, los tipos de parámetros, el tipo con el que está asociado lógicamente el método dinámico y si las comprobaciones de visibilidad Just-In-Time (JIT) deben omitirse para los tipos y miembros a Microsoft los que accede el lenguaje intermedio (MSIL) del método dinámico. |
| DynamicMethod(String, Type, Type[], Boolean) |
Inicializa un método dinámico hospedado de forma anónima, especificando el nombre del método, el tipo de valor devuelto, los tipos de parámetros y si las comprobaciones de visibilidad Just-In-Time (JIT) deben omitirse para los tipos y miembros a los que accede el lenguaje intermedio (MSIL) de Microsoft del método dinámico. |
| DynamicMethod(String, Type, Type[], Module, Boolean) |
Crea un método dinámico global para un módulo, especificando el nombre del método, el tipo de valor devuelto, los tipos de parámetros, el módulo y si las comprobaciones de visibilidad Just-In-Time (JIT) deben omitirse para los tipos y miembros a Microsoft los que tiene acceso el lenguaje intermedio (MSIL) del método dinámico. |
| DynamicMethod(String, Type, Type[], Module) |
Crea un método dinámico que es global para un módulo, especificando el nombre del método, el tipo de valor devuelto, los tipos de parámetro y el módulo. |
| DynamicMethod(String, Type, Type[], Type, Boolean) |
Crea un método dinámico, especificando el nombre del método, el tipo de valor devuelto, los tipos de parámetros, el tipo con el que está asociado lógicamente el método dinámico y si las comprobaciones de visibilidad Just-In-Time (JIT) deben omitirse para los tipos y miembros a Microsoft los que accede el lenguaje intermedio (MSIL) del método dinámico. |
| DynamicMethod(String, Type, Type[], Type) |
Crea un método dinámico, especificando el nombre del método, el tipo de valor devuelto, los tipos de parámetro y el tipo con el que el método dinámico está asociado lógicamente. |
| DynamicMethod(String, Type, Type[]) |
Inicializa un método dinámico hospedado de forma anónima, especificando el nombre del método, el tipo de valor devuelto y los tipos de parámetro. |
Propiedades
| Nombre | Description |
|---|---|
| Attributes |
Obtiene los atributos especificados cuando se creó el método dinámico. |
| CallingConvention |
Obtiene la convención de llamada especificada cuando se creó el método dinámico. |
| ContainsGenericParameters |
Obtiene un valor que indica si un método genérico contiene parámetros de tipo genérico sin asignar. (Heredado de MethodInfo) |
| CustomAttributes |
Obtiene una colección que contiene los atributos personalizados de este miembro. (Heredado de MemberInfo) |
| DeclaringType |
Obtiene el tipo que declara el método , que siempre |
| InitLocals |
Obtiene o establece un valor que indica si las variables locales del método se inicializan en cero. |
| IsAbstract |
Obtiene un valor que indica si el método es abstracto. (Heredado de MethodBase) |
| IsAssembly |
Obtiene un valor que indica si la posible visibilidad de este método o constructor se describe mediante Assembly; es decir, el método o constructor es visible como máximo para otros tipos del mismo ensamblado y no es visible para los tipos derivados fuera del ensamblado. (Heredado de MethodBase) |
| IsConstructedGenericMethod |
Define y representa un método dinámico que se puede compilar, ejecutar y descartar. Los métodos descartados están disponibles para la recolección de elementos no utilizados. (Heredado de MethodBase) |
| IsConstructor |
Obtiene un valor que indica si el método es un constructor. (Heredado de MethodBase) |
| IsFamily |
Obtiene un valor que indica si la visibilidad de este método o constructor se describe mediante Family; es decir, el método o constructor solo está visible dentro de su clase y clases derivadas. (Heredado de MethodBase) |
| IsFamilyAndAssembly |
Obtiene un valor que indica si la visibilidad de este método o constructor se describe mediante FamANDAssem; es decir, las clases derivadas pueden llamar al método o constructor, pero solo si están en el mismo ensamblado. (Heredado de MethodBase) |
| IsFamilyOrAssembly |
Obtiene un valor que indica si la posible visibilidad de este método o constructor se describe mediante FamORAssem; es decir, las clases derivadas pueden llamar al método o constructor dondequiera que estén y por clases del mismo ensamblado. (Heredado de MethodBase) |
| IsFinal |
Obtiene un valor que indica si este método es |
| IsGenericMethod |
Obtiene un valor que indica si el método actual es un método genérico. (Heredado de MethodInfo) |
| IsGenericMethodDefinition |
Obtiene un valor que indica si el objeto actual MethodInfo representa la definición de un método genérico. (Heredado de MethodInfo) |
| IsHideBySig |
Obtiene un valor que indica si solo un miembro del mismo tipo con exactamente la misma firma está oculto en la clase derivada. (Heredado de MethodBase) |
| IsPrivate |
Obtiene un valor que indica si este miembro es privado. (Heredado de MethodBase) |
| IsPublic |
Obtiene un valor que indica si se trata de un método público. (Heredado de MethodBase) |
| IsSecurityCritical |
Obtiene un valor que indica si el método dinámico actual es crítico para la seguridad o crítico para la seguridad y, por tanto, puede realizar operaciones críticas. |
| IsSecurityCritical |
Obtiene un valor que indica si el método o constructor actual es crítico para la seguridad o crítico para la seguridad en el nivel de confianza actual y, por tanto, puede realizar operaciones críticas. (Heredado de MethodBase) |
| IsSecuritySafeCritical |
Obtiene un valor que indica si el método dinámico actual es crítico para la seguridad en el nivel de confianza actual; es decir, si puede realizar operaciones críticas y se puede acceder a ellas mediante código transparente. |
| IsSecuritySafeCritical |
Obtiene un valor que indica si el método o constructor actual es crítico para la seguridad en el nivel de confianza actual; es decir, si puede realizar operaciones críticas y se puede acceder a ellas mediante código transparente. (Heredado de MethodBase) |
| IsSecurityTransparent |
Obtiene un valor que indica si el método dinámico actual es transparente en el nivel de confianza actual y, por tanto, no puede realizar operaciones críticas. |
| IsSecurityTransparent |
Obtiene un valor que indica si el método o constructor actual es transparente en el nivel de confianza actual y, por tanto, no puede realizar operaciones críticas. (Heredado de MethodBase) |
| IsSpecialName |
Obtiene un valor que indica si este método tiene un nombre especial. (Heredado de MethodBase) |
| IsStatic |
Obtiene un valor que indica si el método es |
| IsVirtual |
Obtiene un valor que indica si el método es |
| MemberType |
Obtiene un MemberTypes valor que indica que este miembro es un método. (Heredado de MethodInfo) |
| MetadataToken |
Obtiene un valor que identifica un elemento de metadatos. (Heredado de MemberInfo) |
| MethodHandle |
No se admite para métodos dinámicos. |
| MethodImplementationFlags |
Obtiene las MethodImplAttributes marcas que especifican los atributos de una implementación de método. (Heredado de MethodBase) |
| Module |
Obtiene el módulo con el que el método dinámico está asociado lógicamente. |
| Module |
Obtiene el módulo en el que se define el tipo que declara el miembro representado por el actual MemberInfo . (Heredado de MemberInfo) |
| Name |
Obtiene el nombre del método dinámico. |
| ReflectedType |
Obtiene la clase que se usó en la reflexión para obtener el método . |
| ReturnParameter |
Obtiene el parámetro return del método dinámico. |
| ReturnType |
Obtiene el tipo de valor devuelto para el método dinámico. |
| ReturnTypeCustomAttributes |
Obtiene los atributos personalizados del tipo de valor devuelto para el método dinámico. |
Métodos
| Nombre | Description |
|---|---|
| CreateDelegate(Type, Object) |
Completa el método dinámico y crea un delegado que se puede usar para ejecutarlo, especificando el tipo de delegado y un objeto al que está enlazado el delegado. |
| CreateDelegate(Type) |
Completa el método dinámico y crea un delegado que se puede usar para ejecutarlo. |
| DefineParameter(Int32, ParameterAttributes, String) |
Define un parámetro del método dinámico. |
| Equals(Object) |
Devuelve un valor que indica si esta instancia es igual a un objeto especificado. (Heredado de MethodInfo) |
| GetBaseDefinition() |
Devuelve la implementación base del método . |
| GetCustomAttributes(Boolean) |
Devuelve todos los atributos personalizados definidos para el método . |
| GetCustomAttributes(Type, Boolean) |
Devuelve los atributos personalizados del tipo especificado que se han aplicado al método . |
| GetCustomAttributesData() |
Devuelve una lista de CustomAttributeData objetos que representan datos sobre los atributos que se han aplicado al miembro de destino. (Heredado de MemberInfo) |
| GetDynamicILInfo() |
Devuelve un objeto DynamicILInfo que se puede usar para generar un cuerpo de método a partir de tokens de metadatos, ámbitos y flujos Microsoft de lenguaje intermedio (MSIL). |
| GetGenericArguments() |
Devuelve una matriz de Type objetos que representan los argumentos de tipo de un método genérico o los parámetros de tipo de una definición de método genérico. (Heredado de MethodInfo) |
| GetGenericMethodDefinition() |
Devuelve un MethodInfo objeto que representa una definición de método genérica a partir de la cual se puede construir el método actual. (Heredado de MethodInfo) |
| GetHashCode() |
Devuelve el código hash de esta instancia. (Heredado de MethodInfo) |
| GetILGenerator() |
Devuelve un generador de Microsoft lenguaje intermedio (MSIL) para el método con un tamaño de flujo MSIL predeterminado de 64 bytes. |
| GetILGenerator(Int32) |
Devuelve un generador de lenguaje intermedio (MSIL) Microsoft para el método con el tamaño de flujo MSIL especificado. |
| GetMethodBody() |
Cuando se reemplaza en una clase derivada, obtiene un MethodBody objeto que proporciona acceso a la secuencia de MSIL, las variables locales y las excepciones para el método actual. (Heredado de MethodBase) |
| GetMethodImplementationFlags() |
Devuelve las marcas de implementación del método . |
| GetParameters() |
Devuelve los parámetros del método dinámico. |
| HasSameMetadataDefinitionAs(MemberInfo) |
Define y representa un método dinámico que se puede compilar, ejecutar y descartar. Los métodos descartados están disponibles para la recolección de elementos no utilizados. (Heredado de MemberInfo) |
| Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) |
Invoca el método dinámico mediante los parámetros especificados, bajo las restricciones del enlazador especificado, con la información de referencia cultural especificada. |
| IsDefined(Type, Boolean) |
Indica si se define el tipo de atributo personalizado especificado. |
| MakeGenericMethod(Type[]) |
Sustituye los elementos de una matriz de tipos para los parámetros de tipo de la definición de método genérico actual y devuelve un MethodInfo objeto que representa el método construido resultante. (Heredado de MethodInfo) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| ToString() |
Devuelve la firma del método, representada como una cadena. |
Implementaciones de interfaz explícitas
| Nombre | Description |
|---|---|
| _MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío. (Heredado de MemberInfo) |
| _MemberInfo.GetType() |
Obtiene un Type objeto que representa la MemberInfo clase . (Heredado de MemberInfo) |
| _MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera la información de tipo de un objeto, que se puede usar después para obtener la información de tipo de una interfaz. (Heredado de MemberInfo) |
| _MemberInfo.GetTypeInfoCount(UInt32) |
Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1). (Heredado de MemberInfo) |
| _MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Proporciona acceso a propiedades y métodos expuestos por un objeto . (Heredado de MemberInfo) |
| _MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío. (Heredado de MethodBase) |
| _MethodBase.GetType() |
Para obtener una descripción de este miembro, vea GetType(). (Heredado de MethodBase) |
| _MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera la información de tipo de un objeto, que se puede usar después para obtener la información de tipo de una interfaz. (Heredado de MethodBase) |
| _MethodBase.GetTypeInfoCount(UInt32) |
Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1). (Heredado de MethodBase) |
| _MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Proporciona acceso a propiedades y métodos expuestos por un objeto . (Heredado de MethodBase) |
| _MethodBase.IsAbstract |
Para obtener una descripción de este miembro, vea IsAbstract. (Heredado de MethodBase) |
| _MethodBase.IsAssembly |
Para obtener una descripción de este miembro, vea IsAssembly. (Heredado de MethodBase) |
| _MethodBase.IsConstructor |
Para obtener una descripción de este miembro, vea IsConstructor. (Heredado de MethodBase) |
| _MethodBase.IsFamily |
Para obtener una descripción de este miembro, vea IsFamily. (Heredado de MethodBase) |
| _MethodBase.IsFamilyAndAssembly |
Para obtener una descripción de este miembro, vea IsFamilyAndAssembly. (Heredado de MethodBase) |
| _MethodBase.IsFamilyOrAssembly |
Para obtener una descripción de este miembro, vea IsFamilyOrAssembly. (Heredado de MethodBase) |
| _MethodBase.IsFinal |
Para obtener una descripción de este miembro, vea IsFinal. (Heredado de MethodBase) |
| _MethodBase.IsHideBySig |
Para obtener una descripción de este miembro, vea IsHideBySig. (Heredado de MethodBase) |
| _MethodBase.IsPrivate |
Para obtener una descripción de este miembro, vea IsPrivate. (Heredado de MethodBase) |
| _MethodBase.IsPublic |
Para obtener una descripción de este miembro, vea IsPublic. (Heredado de MethodBase) |
| _MethodBase.IsSpecialName |
Para obtener una descripción de este miembro, vea IsSpecialName. (Heredado de MethodBase) |
| _MethodBase.IsStatic |
Para obtener una descripción de este miembro, vea IsStatic. (Heredado de MethodBase) |
| _MethodBase.IsVirtual |
Para obtener una descripción de este miembro, vea IsVirtual. (Heredado de MethodBase) |
| _MethodInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío. (Heredado de MethodInfo) |
| _MethodInfo.GetType() |
Proporciona acceso al GetType() método desde COM. (Heredado de MethodInfo) |
| _MethodInfo.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera la información de tipo de un objeto, que se puede usar para obtener la información de tipo de una interfaz. (Heredado de MethodInfo) |
| _MethodInfo.GetTypeInfoCount(UInt32) |
Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1). (Heredado de MethodInfo) |
| _MethodInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Proporciona acceso a propiedades y métodos expuestos por un objeto . (Heredado de MethodInfo) |
Métodos de extensión
| Nombre | Description |
|---|---|
| GetCustomAttribute(MemberInfo, Type, Boolean) |
Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro especificado y, opcionalmente, inspecciona los antecesores de ese miembro. |
| GetCustomAttribute(MemberInfo, Type) |
Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro especificado. |
| GetCustomAttribute<T>(MemberInfo, Boolean) |
Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro especificado y, opcionalmente, inspecciona los antecesores de ese miembro. |
| GetCustomAttribute<T>(MemberInfo) |
Recupera un atributo personalizado de un tipo especificado que se aplica a un miembro especificado. |
| GetCustomAttributes(MemberInfo, Boolean) |
Recupera una colección de atributos personalizados que se aplican a un miembro especificado y, opcionalmente, inspecciona los antecesores de ese miembro. |
| GetCustomAttributes(MemberInfo, Type, Boolean) |
Recupera una colección de atributos personalizados de un tipo especificado que se aplica a un miembro especificado y, opcionalmente, inspecciona los antecesores de ese miembro. |
| GetCustomAttributes(MemberInfo, Type) |
Recupera una colección de atributos personalizados de un tipo especificado que se aplica a un miembro especificado. |
| GetCustomAttributes(MemberInfo) |
Recupera una colección de atributos personalizados que se aplican a un miembro especificado. |
| GetCustomAttributes<T>(MemberInfo, Boolean) |
Recupera una colección de atributos personalizados de un tipo especificado que se aplica a un miembro especificado y, opcionalmente, inspecciona los antecesores de ese miembro. |
| GetCustomAttributes<T>(MemberInfo) |
Recupera una colección de atributos personalizados de un tipo especificado que se aplica a un miembro especificado. |
| GetRuntimeBaseDefinition(MethodInfo) |
Recupera un objeto que representa el método especificado en la clase base directa o indirecta donde el método se declaró por primera vez. |
| IsDefined(MemberInfo, Type, Boolean) |
Indica si los atributos personalizados de un tipo especificado se aplican a un miembro especificado y, opcionalmente, se aplican a sus antecesores. |
| IsDefined(MemberInfo, Type) |
Indica si los atributos personalizados de un tipo especificado se aplican a un miembro especificado. |