DynamicMethod 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컴파일, 실행 및 삭제할 수 있는 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다.
public ref class DynamicMethod sealed : System::Reflection::MethodInfo
public sealed class DynamicMethod : System.Reflection.MethodInfo
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DynamicMethod : System.Reflection.MethodInfo
type DynamicMethod = class
inherit MethodInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
type DynamicMethod = class
inherit MethodInfo
Public NotInheritable Class DynamicMethod
Inherits MethodInfo
- 상속
- 특성
예제
다음 코드 예제에서는 두 개의 매개 변수를 사용하는 동적 메서드를 만듭니다. 이 예제에서는 첫 번째 매개 변수를 콘솔에 출력하는 간단한 함수 본문을 내보내고 두 번째 매개 변수를 메서드의 반환 값으로 사용합니다. 이 예제는 대리자를 생성하여 메서드를 완성한 후, 다른 매개변수로 대리자를 호출하고, 마지막으로 Invoke 메서드를 사용하여 동적 메서드를 호출합니다.
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
public class Test
{
// Declare a delegate type that can be used to execute the completed
// dynamic method.
private delegate int HelloDelegate(string msg, int ret);
public static void Main()
{
// Create an array that specifies the types of the parameters
// of the dynamic method. This dynamic method has a String
// parameter and an Integer parameter.
Type[] helloArgs = {typeof(string), typeof(int)};
// Create a dynamic method with the name "Hello", a return type
// of Integer, and two parameters whose types are specified by
// the array helloArgs. Create the method in the module that
// defines the String class.
DynamicMethod hello = new DynamicMethod("Hello",
typeof(int),
helloArgs,
typeof(string).Module);
// Create an array that specifies the parameter types of the
// overload of Console.WriteLine to be used in Hello.
Type[] writeStringArgs = {typeof(string)};
// Get the overload of Console.WriteLine that has one
// String parameter.
MethodInfo writeString = typeof(Console).GetMethod("WriteLine",
writeStringArgs);
// Get an ILGenerator and emit a body for the dynamic method,
// using a stream size larger than the IL that will be
// emitted.
ILGenerator il = hello.GetILGenerator(256);
// Load the first argument, which is a string, onto the stack.
il.Emit(OpCodes.Ldarg_0);
// Call the overload of Console.WriteLine that prints a string.
il.EmitCall(OpCodes.Call, writeString, null);
// The Hello method returns the value of the second argument;
// to do this, load the onto the stack and return.
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Ret);
// Add parameter information to the dynamic method. (This is not
// necessary, but can be useful for debugging.) For each parameter,
// identified by position, supply the parameter attributes and a
// parameter name.
hello.DefineParameter(1, ParameterAttributes.In, "message");
hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn");
// Create a delegate that represents the dynamic method. This
// action completes the method. Any further attempts to
// change the method are ignored.
HelloDelegate hi =
(HelloDelegate) hello.CreateDelegate(typeof(HelloDelegate));
// Use the delegate to execute the dynamic method.
Console.WriteLine("\r\nUse the delegate to execute the dynamic method:");
int retval = hi("\r\nHello, World!", 42);
Console.WriteLine("Invoking delegate hi(\"Hello, World!\", 42) returned: " + retval);
// Execute it again, with different arguments.
retval = hi("\r\nHi, Mom!", 5280);
Console.WriteLine("Invoking delegate hi(\"Hi, Mom!\", 5280) returned: " + retval);
Console.WriteLine("\r\nUse the Invoke method to execute the dynamic method:");
// Create an array of arguments to use with the Invoke method.
object[] invokeArgs = {"\r\nHello, World!", 42};
// Invoke the dynamic method using the arguments. This is much
// slower than using the delegate, because you must create an
// array to contain the arguments, and value-type arguments
// must be boxed.
object objRet = hello.Invoke(null, BindingFlags.ExactBinding, null, invokeArgs, new CultureInfo("en-us"));
Console.WriteLine("hello.Invoke returned: " + objRet);
Console.WriteLine("\r\n ----- Display information about the dynamic method -----");
// Display MethodAttributes for the dynamic method, set when
// the dynamic method was created.
Console.WriteLine("\r\nMethod Attributes: {0}", hello.Attributes);
// Display the calling convention of the dynamic method, set when the
// dynamic method was created.
Console.WriteLine("\r\nCalling convention: {0}", hello.CallingConvention);
// Display the declaring type, which is always null for dynamic
// methods.
if (hello.DeclaringType == null)
{
Console.WriteLine("\r\nDeclaringType is always null for dynamic methods.");
}
else
{
Console.WriteLine("DeclaringType: {0}", hello.DeclaringType);
}
// Display the default value for InitLocals.
if (hello.InitLocals)
{
Console.Write("\r\nThis method contains verifiable code.");
}
else
{
Console.Write("\r\nThis method contains unverifiable code.");
}
Console.WriteLine(" (InitLocals = {0})", hello.InitLocals);
// Display the module specified when the dynamic method was created.
Console.WriteLine("\r\nModule: {0}", hello.Module);
// Display the name specified when the dynamic method was created.
// Note that the name can be blank.
Console.WriteLine("\r\nName: {0}", hello.Name);
// For dynamic methods, the reflected type is always null.
if (hello.ReflectedType == null)
{
Console.WriteLine("\r\nReflectedType is null.");
}
else
{
Console.WriteLine("\r\nReflectedType: {0}", hello.ReflectedType);
}
if (hello.ReturnParameter == null)
{
Console.WriteLine("\r\nMethod has no return parameter.");
}
else
{
Console.WriteLine("\r\nReturn parameter: {0}", hello.ReturnParameter);
}
// If the method has no return type, ReturnType is System.Void.
Console.WriteLine("\r\nReturn type: {0}", hello.ReturnType);
// ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
// that can be used to enumerate the custom attributes of the
// return value. At present, there is no way to set such custom
// attributes, so the list is empty.
if (hello.ReturnType == typeof(void))
{
Console.WriteLine("The method has no return type.");
}
else
{
ICustomAttributeProvider caProvider = hello.ReturnTypeCustomAttributes;
object[] returnAttributes = caProvider.GetCustomAttributes(true);
if (returnAttributes.Length == 0)
{
Console.WriteLine("\r\nThe return type has no custom attributes.");
}
else
{
Console.WriteLine("\r\nThe return type has the following custom attributes:");
foreach( object attr in returnAttributes )
{
Console.WriteLine("\t{0}", attr.ToString());
}
}
}
Console.WriteLine("\r\nToString: {0}", hello.ToString());
// Display parameter information.
ParameterInfo[] parameters = hello.GetParameters();
Console.WriteLine("\r\nParameters: name, type, ParameterAttributes");
foreach( ParameterInfo p in parameters )
{
Console.WriteLine("\t{0}, {1}, {2}",
p.Name, p.ParameterType, p.Attributes);
}
}
}
/* This code example produces the following output:
Use the delegate to execute the dynamic method:
Hello, World!
Invoking delegate hi("Hello, World!", 42) returned: 42
Hi, Mom!
Invoking delegate hi("Hi, Mom!", 5280) returned: 5280
Use the Invoke method to execute the dynamic method:
Hello, World!
hello.Invoke returned: 42
----- Display information about the dynamic method -----
Method Attributes: PrivateScope, Public, Static
Calling convention: Standard
DeclaringType is always null for dynamic methods.
This method contains verifiable code. (InitLocals = True)
Module: CommonLanguageRuntimeLibrary
Name: Hello
ReflectedType is null.
Method has no return parameter.
Return type: System.Int32
The return type has no custom attributes.
ToString: Int32 Hello(System.String, Int32)
Parameters: name, type, ParameterAttributes
message, System.String, In
valueToReturn, System.Int32, In
*/
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Globalization
Public Class Test
' Declare a delegate type that can be used to execute the completed
' dynamic method.
Private Delegate Function HelloDelegate(ByVal msg As String, _
ByVal ret As Integer) As Integer
Public Shared Sub Main()
' Create an array that specifies the types of the parameters
' of the dynamic method. This dynamic method has a String
' parameter and an Integer parameter.
Dim helloArgs() As Type = {GetType(String), GetType(Integer)}
' Create a dynamic method with the name "Hello", a return type
' of Integer, and two parameters whose types are specified by
' the array helloArgs. Create the method in the module that
' defines the String class.
Dim hello As New DynamicMethod("Hello", _
GetType(Integer), _
helloArgs, _
GetType(String).Module)
' Create an array that specifies the parameter types of the
' overload of Console.WriteLine to be used in Hello.
Dim writeStringArgs() As Type = {GetType(String)}
' Get the overload of Console.WriteLine that has one
' String parameter.
Dim writeString As MethodInfo = GetType(Console). _
GetMethod("WriteLine", writeStringArgs)
' Get an ILGenerator and emit a body for the dynamic method,
' using a stream size larger than the IL that will be
' emitted.
Dim il As ILGenerator = hello.GetILGenerator(256)
' Load the first argument, which is a string, onto the stack.
il.Emit(OpCodes.Ldarg_0)
' Call the overload of Console.WriteLine that prints a string.
il.EmitCall(OpCodes.Call, writeString, Nothing)
' The Hello method returns the value of the second argument;
' to do this, load the onto the stack and return.
il.Emit(OpCodes.Ldarg_1)
il.Emit(OpCodes.Ret)
' Add parameter information to the dynamic method. (This is not
' necessary, but can be useful for debugging.) For each parameter,
' identified by position, supply the parameter attributes and a
' parameter name.
hello.DefineParameter(1, ParameterAttributes.In, "message")
hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn")
' Create a delegate that represents the dynamic method. This
' action completes the method. Any further attempts to
' change the method are ignored.
Dim hi As HelloDelegate = _
CType(hello.CreateDelegate(GetType(HelloDelegate)), HelloDelegate)
' Use the delegate to execute the dynamic method.
Console.WriteLine(vbCrLf & "Use the delegate to execute the dynamic method:")
Dim retval As Integer = hi(vbCrLf & "Hello, World!", 42)
Console.WriteLine("Invoking delegate hi(""Hello, World!"", 42) returned: " _
& retval & ".")
' Execute it again, with different arguments.
retval = hi(vbCrLf & "Hi, Mom!", 5280)
Console.WriteLine("Invoking delegate hi(""Hi, Mom!"", 5280) returned: " _
& retval & ".")
Console.WriteLine(vbCrLf & "Use the Invoke method to execute the dynamic method:")
' Create an array of arguments to use with the Invoke method.
Dim invokeArgs() As Object = {vbCrLf & "Hello, World!", 42}
' Invoke the dynamic method using the arguments. This is much
' slower than using the delegate, because you must create an
' array to contain the arguments, and value-type arguments
' must be boxed.
Dim objRet As Object = hello.Invoke(Nothing, _
BindingFlags.ExactBinding, Nothing, invokeArgs, _
New CultureInfo("en-us"))
Console.WriteLine("hello.Invoke returned: {0}", objRet)
Console.WriteLine(vbCrLf & _
" ----- Display information about the dynamic method -----")
' Display MethodAttributes for the dynamic method, set when
' the dynamic method was created.
Console.WriteLine(vbCrLf & "Method Attributes: {0}", _
hello.Attributes)
' Display the calling convention of the dynamic method, set when the
' dynamic method was created.
Console.WriteLine(vbCrLf & "Calling convention: {0}", _
hello.CallingConvention)
' Display the declaring type, which is always Nothing for dynamic
' methods.
If hello.DeclaringType Is Nothing Then
Console.WriteLine(vbCrLf & "DeclaringType is always Nothing for dynamic methods.")
Else
Console.WriteLine("DeclaringType: {0}", hello.DeclaringType)
End If
' Display the default value for InitLocals.
If hello.InitLocals Then
Console.Write(vbCrLf & "This method contains verifiable code.")
Else
Console.Write(vbCrLf & "This method contains unverifiable code.")
End If
Console.WriteLine(" (InitLocals = {0})", hello.InitLocals)
' Display the module specified when the dynamic method was created.
Console.WriteLine(vbCrLf & "Module: {0}", hello.Module)
' Display the name specified when the dynamic method was created.
' Note that the name can be blank.
Console.WriteLine(vbCrLf & "Name: {0}", hello.Name)
' For dynamic methods, the reflected type is always Nothing.
If hello.ReflectedType Is Nothing Then
Console.WriteLine(vbCrLf & "ReflectedType is Nothing.")
Else
Console.WriteLine(vbCrLf & "ReflectedType: {0}", _
hello.ReflectedType)
End If
If hello.ReturnParameter Is Nothing Then
Console.WriteLine(vbCrLf & "Method has no return parameter.")
Else
Console.WriteLine(vbCrLf & "Return parameter: {0}", _
hello.ReturnParameter)
End If
' If the method has no return type, ReturnType is System.Void.
Console.WriteLine(vbCrLf & "Return type: {0}", hello.ReturnType)
' ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
' that can be used to enumerate the custom attributes of the
' return value. At present, there is no way to set such custom
' attributes, so the list is empty.
If hello.ReturnType Is GetType(System.Void) Then
Console.WriteLine("The method has no return type.")
Else
Dim caProvider As ICustomAttributeProvider = _
hello.ReturnTypeCustomAttributes
Dim returnAttributes() As Object = _
caProvider.GetCustomAttributes(True)
If returnAttributes.Length = 0 Then
Console.WriteLine(vbCrLf _
& "The return type has no custom attributes.")
Else
Console.WriteLine(vbCrLf _
& "The return type has the following custom attributes:")
For Each attr As Object In returnAttributes
Console.WriteLine(vbTab & attr.ToString())
Next attr
End If
End If
Console.WriteLine(vbCrLf & "ToString: " & hello.ToString())
' Display parameter information.
Dim parameters() As ParameterInfo = hello.GetParameters()
Console.WriteLine(vbCrLf & "Parameters: name, type, ParameterAttributes")
For Each p As ParameterInfo In parameters
Console.WriteLine(vbTab & "{0}, {1}, {2}", _
p.Name, p.ParameterType, p.Attributes)
Next p
End Sub
End Class
' This code example produces the following output:
'
'Use the delegate to execute the dynamic method:
'
'Hello, World!
'Invoking delegate hi("Hello, World!", 42) returned: 42.
'
'Hi, Mom!
'Invoking delegate hi("Hi, Mom!", 5280) returned: 5280.
'
'Use the Invoke method to execute the dynamic method:
'
'Hello, World!
'hello.Invoke returned: 42
'
' ----- Display information about the dynamic method -----
'
'Method Attributes: PrivateScope, Public, Static
'
'Calling convention: Standard
'
'DeclaringType is always Nothing for dynamic methods.
'
'This method contains verifiable code. (InitLocals = True)
'
'Module: CommonLanguageRuntimeLibrary
'
'Name: Hello
'
'ReflectedType is Nothing.
'
'Method has no return parameter.
'
'Return type: System.Int32
'
'The return type has no custom attributes.
'
'ToString: Int32 Hello(System.String, Int32)
'
'Parameters: name, type, ParameterAttributes
' message, System.String, In
' valueToReturn, System.Int32, In
설명
클래스를 DynamicMethod 사용하여 메서드를 포함할 동적 어셈블리 및 동적 형식을 생성하지 않고도 런타임에 메서드를 생성하고 실행할 수 있습니다. JIT 컴파일러에서 생성한 실행 코드는 개체가 DynamicMethod 회수될 때 함께 회수됩니다. 동적 메서드는 소량의 코드를 생성하고 실행하는 가장 효율적인 방법입니다.
동적 메서드는 익명으로 호스트되거나 모듈 또는 형식과 논리적으로 연결될 수 있습니다.
동적 메서드가 익명으로 호스트되는 경우 시스템 제공 어셈블리에 있으므로 다른 코드와 격리됩니다. 기본적으로 공용이 아닌 데이터에 대한 액세스 권한은 없습니다. 익명으로 호스트되는 동적 메서드는 ReflectionPermission 플래그로 ReflectionPermissionFlag.RestrictedMemberAccess 부여된 경우 JIT 컴파일러의 가시성 검사를 건너뛰는 기능이 제한될 수 있습니다. 동적 메서드에서 비공용 멤버에 액세스하는 어셈블리의 신뢰 수준은 동적 메서드를 내보낸 호출 스택의 신뢰 수준 또는 하위 집합과 같아야 합니다. 익명으로 호스트되는 동적 메서드에 대한 자세한 내용은 연습: 부분 신뢰 시나리오에서 코드 내보내기를 참조하세요.
동적 메서드가 지정한 모듈과 연결된 경우 동적 메서드는 해당 모듈에 효과적으로 전역화됩니다. 모듈의 모든 형식과 형식의 모든
internal(FriendVisual Basic) 멤버에 액세스할 수 있습니다. 코드를 포함하는 호출 스택에서 플래그에 대한 ReflectionPermission 요구를 충족할 수 있는 경우 모듈을 만들었는지 여부에 관계없이 동적 메서드를 모듈과 RestrictedMemberAccess 연결할 수 있습니다. 권한 부여에 ReflectionPermissionFlag.MemberAccess 플래그가 포함된 경우 동적 메서드는 JIT 컴파일러의 가시성 검사를 건너뛰고 모듈 또는 어셈블리의 다른 모듈에 선언된 모든 형식의 프라이빗 데이터에 액세스할 수 있습니다.메모
동적 메서드가 연결된 모듈을 지정하는 경우 해당 모듈은 익명 호스팅에 사용되는 시스템 제공 어셈블리에 있으면 안 됩니다.
동적 메서드가 지정한 형식과 연결된 경우 액세스 수준에 관계없이 형식의 모든 멤버에 액세스할 수 있습니다. 또한 JIT 가시성 검사를 건너뛸 수 있습니다. 이렇게 하면 동적 메서드가 동일한 모듈 또는 어셈블리의 다른 모듈에 선언된 다른 형식의 프라이빗 데이터에 액세스할 수 있습니다. 동적 메서드는 모든 형식과 연결할 수 있습니다. 그러나 코드에 ReflectionPermission가 부여되려면 RestrictedMemberAccess와 MemberAccess 플래그 모두가 포함되어야 합니다.
다음 표는 플래그가 ReflectionPermission 부여된 경우와 그렇지 않은 경우(RestrictedMemberAccess) JIT 표시 여부 검사에 따라 익명으로 호스트되는 동적 메서드에서 액세스할 수 있는 형식과 멤버를 보여줍니다.
| 가시성 검사 |
RestrictedMemberAccess이 없는 경우 |
RestrictedMemberAccess와 함께 |
|---|---|---|
| JIT 가시성 검사를 건너뛰지 않고 | 모든 어셈블리에 있는 public 형식의 공용 멤버입니다. | 모든 어셈블리에 있는 public 형식의 공용 멤버입니다. |
| 제한된 상태에서 JIT 가시성 검사 건너뛰기 | 모든 어셈블리에 있는 public 형식의 공용 멤버입니다. | 동적 메서드를 내보낸 어셈블리의 신뢰 수준과 같거나 작은 신뢰 수준을 가진 어셈블리에서만 모든 형식의 모든 멤버가 가능합니다. |
다음 표에서는 모듈 또는 모듈의 형식과 연결된 동적 메서드에 액세스할 수 있는 형식과 멤버를 보여 있습니다.
| JIT 가시성 검사 건너뛰기 | 모듈과 연결됨 | 형식과 연결됨 |
|---|---|---|
| 아니오 | 모듈 내의 공용, 내부 및 프라이빗 형식의 멤버들 중 공용 및 내부 멤버입니다. 모든 어셈블리에 있는 public 형식의 공용 멤버입니다. |
연관된 유형의 모든 멤버입니다. 모듈에 있는 다른 모든 형식의 공용 및 내부 멤버입니다. 모든 어셈블리에 있는 public 형식의 공용 멤버입니다. |
| Yes | 모든 조립체에 있는 모든 종류의 모든 멤버입니다. | 모든 조립체에 있는 모든 종류의 모든 멤버입니다. |
모듈과 연결된 동적 메서드에는 해당 모듈의 권한이 있습니다. 형식과 연결된 동적 메서드에는 해당 형식을 포함하는 모듈의 권한이 있습니다.
동적 메서드 및 해당 매개 변수의 이름을 지정할 필요는 없지만 디버깅에 도움이 되는 이름을 지정할 수 있습니다. 사용자 지정 특성은 동적 메서드 또는 해당 매개 변수에서 지원되지 않습니다.
동적 메서드는 static 메서드(Shared Visual Basic의 메서드)이지만 대리자 바인딩에 대한 완화된 규칙을 사용하면 동적 메서드를 개체에 바인딩할 수 있으므로 해당 대리자 인스턴스를 사용하여 호출할 때 인스턴스 메서드처럼 작동합니다. 이것을 설명하는 예가 CreateDelegate(Type, Object) 메서드 오버로드에 대해 제공되었습니다.
검증
다음 목록에는 동적 메서드에 확인할 수 없는 코드가 포함될 수 있는 조건이 요약되어 있습니다. 예를 들어, InitLocals 속성이 false으로 설정된 경우 그 동적 메서드는 검증할 수 없습니다.
- 보안에 중요한 어셈블리와 연결된 동적 메서드도 보안에 중요하며 확인을 건너뛸 수 있습니다. 예를 들어 데스크톱 애플리케이션으로 실행되는 보안 특성이 없는 어셈블리는 런타임에서 보안에 중요한 것으로 처리됩니다. 동적 메서드를 어셈블리와 연결하면 동적 메서드에 확인할 수 없는 코드가 포함될 수 있습니다.
- 확인되지 않는 코드를 포함하는 동적 메서드가 수준 1 투명도가 있는 어셈블리와 연결된 경우 JIT(Just-In-Time) 컴파일러는 보안 요구를 주입합니다. 동적 메서드가 완전히 신뢰할 수 있는 코드에 의해 실행되는 경우에만 요청이 성공합니다. Security-Transparent 코드, 수준 1을 참조하세요.
- 확인되지 않는 코드를 포함하는 동적 메서드가 수준 2 투명도(예: mscorlib.dll)가 있는 어셈블리와 연결된 경우 보안 요구 대신 예외(JIT 컴파일러에 의해 삽입됨)를 throw합니다. Security-Transparent 코드, 수준 2를 참조하세요.
- 확인되지 않는 코드를 포함하는 익명으로 호스트된 동적 메서드는 항상 예외를 throw합니다. 완전히 신뢰할 수 있는 코드에서 만들고 실행하더라도 확인을 건너뛸 수 없습니다.
확인되지 않는 코드에 대해 throw되는 예외는 동적 메서드가 호출되는 방식에 따라 달라집니다. 메서드에서 CreateDelegate 반환된 대리자를 사용하여 동적 메서드를 호출하면 throw VerificationException 됩니다. 동적 메서드를 Invoke 메서드를 사용하여 호출하면 내부 TargetInvocationException와 함께 VerificationException이 throw됩니다.
생성자
| Name | Description |
|---|---|
| DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean) |
메서드 이름, 특성, 호출 규칙, 반환 형식, 매개 변수 형식, 모듈을 지정하고 동적 메서드의 MSIL(Microsoft 중간 언어)에서 액세스하는 형식 및 멤버에 대해 JIT(Just-In-Time) 표시 여부를 지정하여 모듈에 전역적인 동적 메서드를 만듭니다. |
| DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type, Boolean) |
메서드 이름, 특성, 호출 규칙, 반환 형식, 매개 변수 형식, 동적 메서드가 논리적으로 연결된 형식 및 동적 메서드의 MSIL(Microsoft 중간 언어)에서 액세스하는 형식 및 멤버에 대해 JIT(Just-In-Time) 표시 여부를 지정하는 동적 메서드를 만듭니다. |
| DynamicMethod(String, Type, Type[], Boolean) |
메서드 이름, 반환 형식, 매개 변수 형식 및 동적 메서드의 MSIL(Microsoft 중간 언어)에서 액세스하는 형식 및 멤버에 대해 JIT(Just-In-Time) 표시 여부를 지정하여 익명으로 호스트되는 동적 메서드를 초기화합니다. |
| DynamicMethod(String, Type, Type[], Module, Boolean) |
메서드 이름, 반환 형식, 매개 변수 형식, 모듈 및 동적 메서드의 MSIL(Microsoft 중간 언어)에서 액세스하는 형식 및 멤버에 대해 JIT(Just-In-Time) 표시 여부를 지정하여 모듈에 전역적인 동적 메서드를 만듭니다. |
| DynamicMethod(String, Type, Type[], Module) |
메서드 이름, 반환 형식, 매개 변수 형식 및 모듈을 지정하여 모듈에 전역적인 동적 메서드를 만듭니다. |
| DynamicMethod(String, Type, Type[], Type, Boolean) |
메서드 이름, 반환 형식, 매개 변수 형식, 동적 메서드가 논리적으로 연결된 형식 및 동적 메서드의 MSIL(Microsoft 중간 언어)에서 액세스하는 형식 및 멤버에 대해 JIT(Just-In-Time) 표시 여부를 지정하는 동적 메서드를 만듭니다. |
| DynamicMethod(String, Type, Type[], Type) |
메서드 이름, 반환 형식, 매개 변수 형식 및 동적 메서드가 논리적으로 연결된 형식을 지정하는 동적 메서드를 만듭니다. |
| DynamicMethod(String, Type, Type[]) |
메서드 이름, 반환 형식 및 매개 변수 형식을 지정하여 익명으로 호스트되는 동적 메서드를 초기화합니다. |
속성
| Name | Description |
|---|---|
| Attributes |
동적 메서드를 만들 때 지정된 특성을 가져옵니다. |
| CallingConvention |
동적 메서드를 만들 때 지정된 호출 규칙을 가져옵니다. |
| ContainsGenericParameters |
제네릭 메서드에 할당되지 않은 제네릭 형식 매개 변수가 포함되어 있는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodInfo) |
| CustomAttributes |
이 멤버의 사용자 지정 특성을 포함하는 컬렉션을 가져옵니다. (다음에서 상속됨 MemberInfo) |
| DeclaringType |
항상 |
| InitLocals |
메서드의 지역 변수가 0으로 초기화되었는지 여부를 나타내는 값을 가져오거나 설정합니다. |
| IsAbstract |
메서드가 추상인지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsAssembly |
이 메서드 또는 생성자의 Assembly잠재적 표시 여부를 나타내는 값을 가져옵니다. 즉, 메서드 또는 생성자가 동일한 어셈블리의 다른 형식에 가장 많이 표시되며 어셈블리 외부의 파생 형식에는 표시되지 않습니다. (다음에서 상속됨 MethodBase) |
| IsCollectible |
이 MemberInfo 개체가 수집 가능한 AssemblyLoadContext어셈블리에 저장된 하나 이상의 어셈블리를 참조하는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MemberInfo) |
| IsConstructedGenericMethod |
컴파일, 실행 및 삭제할 수 있는 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다. (다음에서 상속됨 MethodBase) |
| IsConstructor |
메서드가 생성자인지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsFamily |
이 메서드 또는 생성자의 Family표시 여부를 나타내는 값을 가져옵니다. 즉, 메서드 또는 생성자가 해당 클래스 및 파생 클래스 내에서만 표시됩니다. (다음에서 상속됨 MethodBase) |
| IsFamilyAndAssembly |
이 메서드 또는 생성자의 FamANDAssem표시 여부를 나타내는 값을 가져옵니다. 즉, 메서드 또는 생성자는 파생 클래스에서 호출할 수 있지만 동일한 어셈블리에 있는 경우에만 호출할 수 있습니다. (다음에서 상속됨 MethodBase) |
| IsFamilyOrAssembly |
이 메서드 또는 생성자의 FamORAssem잠재적 표시 여부를 나타내는 값을 가져옵니다. 즉, 메서드 또는 생성자가 어디에 있든 파생 클래스 및 동일한 어셈블리의 클래스에서 호출할 수 있습니다. (다음에서 상속됨 MethodBase) |
| IsFinal |
이 메서드 |
| IsGenericMethod |
현재 메서드가 제네릭 메서드인지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodInfo) |
| IsGenericMethodDefinition |
현재 MethodInfo 가 제네릭 메서드의 정의를 나타내는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodInfo) |
| IsHideBySig |
정확히 동일한 시그니처를 가진 동일한 종류의 멤버만 파생 클래스에 숨겨져 있는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsPrivate |
이 멤버가 프라이빗인지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsPublic |
public 메서드인지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsSecurityCritical |
현재 동적 메서드가 보안에 중요하거나 보안이 안전한지 여부를 나타내는 값을 가져오므로 중요한 작업을 수행할 수 있습니다. |
| IsSecurityCritical |
현재 메서드 또는 생성자가 현재 신뢰 수준에서 보안에 중요하거나 보안이 안전한지 여부를 나타내는 값을 가져오므로 중요한 작업을 수행할 수 있습니다. (다음에서 상속됨 MethodBase) |
| IsSecuritySafeCritical |
현재 동적 메서드가 현재 신뢰 수준에서 보안에 중요한지 여부를 나타내는 값을 가져옵니다. 즉, 중요한 작업을 수행할 수 있고 투명 코드로 액세스할 수 있는지 여부입니다. |
| IsSecuritySafeCritical |
현재 메서드 또는 생성자가 현재 신뢰 수준에서 보안에 중요한지 여부를 나타내는 값을 가져옵니다. 즉, 중요한 작업을 수행할 수 있고 투명 코드로 액세스할 수 있는지 여부입니다. (다음에서 상속됨 MethodBase) |
| IsSecurityTransparent |
현재 동적 메서드가 현재 신뢰 수준에서 투명하므로 중요한 작업을 수행할 수 없는지 여부를 나타내는 값을 가져옵니다. |
| IsSecurityTransparent |
현재 메서드 또는 생성자가 현재 신뢰 수준에서 투명하므로 중요한 작업을 수행할 수 없는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsSpecialName |
이 메서드에 특별한 이름이 있는지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodBase) |
| IsStatic |
메서드 |
| IsVirtual |
메서드 |
| MemberType |
이 멤버가 MemberTypes 메서드임을 나타내는 값을 가져옵니다. (다음에서 상속됨 MethodInfo) |
| MetadataToken |
메타데이터 요소를 식별하는 값을 가져옵니다. (다음에서 상속됨 MemberInfo) |
| MethodHandle |
동적 메서드에 대해서는 지원되지 않습니다. |
| MethodImplementationFlags |
컴파일, 실행 및 삭제할 수 있는 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다. |
| MethodImplementationFlags |
메서드 구현의 MethodImplAttributes 특성을 지정하는 플래그를 가져옵니다. (다음에서 상속됨 MethodBase) |
| Module |
동적 메서드가 논리적으로 연결된 모듈을 가져옵니다. |
| Module |
현재 MemberInfo 가 나타내는 멤버를 선언하는 형식이 정의된 모듈을 가져옵니다. (다음에서 상속됨 MemberInfo) |
| Name |
동적 메서드의 이름을 가져옵니다. |
| ReflectedType |
리플렉션에서 메서드를 가져오는 데 사용된 클래스를 가져옵니다. |
| ReturnParameter |
동적 메서드의 반환 매개 변수를 가져옵니다. |
| ReturnType |
동적 메서드의 반환 값 형식을 가져옵니다. |
| ReturnTypeCustomAttributes |
동적 메서드에 대한 반환 형식의 사용자 지정 특성을 가져옵니다. |
| ReturnTypeCustomAttributes |
반환 형식에 대한 사용자 지정 특성을 가져옵니다. (다음에서 상속됨 MethodInfo) |
메서드
| Name | Description |
|---|---|
| CreateDelegate(Type, Object) |
동적 메서드를 완료하고 대리자를 실행하는 데 사용할 수 있는 대리자를 만들고 대리자가 바인딩된 대리자 형식과 개체를 지정합니다. |
| CreateDelegate(Type) |
동적 메서드를 완료하고 실행하는 데 사용할 수 있는 대리자를 만듭니다. |
| CreateDelegate<T>() |
이 메서드에서 형식 |
| CreateDelegate<T>(Object) |
이 메서드에서 지정된 대상을 사용하여 형식 |
| DefineParameter(Int32, ParameterAttributes, String) |
동적 메서드의 매개 변수를 정의합니다. |
| Equals(Object) |
이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 MethodInfo) |
| GetBaseDefinition() |
메서드의 기본 구현을 반환합니다. |
| GetBaseDefinition() |
파생 클래스에서 재정의 MethodInfo 된 경우 이 인스턴스에서 나타내는 메서드가 처음 선언된 직접 또는 간접 기본 클래스에서 메서드의 개체를 반환합니다. (다음에서 상속됨 MethodInfo) |
| GetCustomAttributes(Boolean) |
메서드에 대해 정의된 모든 사용자 지정 특성을 반환합니다. |
| GetCustomAttributes(Type, Boolean) |
메서드에 적용된 지정된 형식의 사용자 지정 특성을 반환합니다. |
| GetCustomAttributesData() |
대상 멤버에 적용된 특성에 대한 데이터를 나타내는 개체 목록을 CustomAttributeData 반환합니다. (다음에서 상속됨 MemberInfo) |
| GetDynamicILInfo() |
메타데이터 토큰, 범위 및 MSIL(Microsoft 중간 언어) 스트림에서 메서드 본문을 생성하는 데 사용할 수 있는 DynamicILInfo 개체를 반환합니다. |
| GetGenericArguments() |
제네릭 메서드의 Type 형식 인수 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 개체의 배열을 반환합니다. (다음에서 상속됨 MethodInfo) |
| GetGenericMethodDefinition() |
현재 메서드를 MethodInfo 생성할 수 있는 제네릭 메서드 정의를 나타내는 개체를 반환합니다. (다음에서 상속됨 MethodInfo) |
| GetHashCode() |
이 인스턴스의 해시 코드를 반환합니다. (다음에서 상속됨 MethodInfo) |
| GetILGenerator() |
기본 MSIL 스트림 크기가 64바이트인 메서드의 Microsoft 중간 언어(MSIL) 생성기를 반환합니다. |
| GetILGenerator(Int32) |
지정된 MSIL 스트림 크기의 메서드에 대한 Microsoft MSIL(중간 언어) 생성기를 반환합니다. |
| GetMethodBody() |
파생 클래스에서 재정의되는 경우 현재 메서드에 대한 MSIL 스트림, 지역 변수 및 예외에 대한 액세스를 제공하는 개체를 가져옵니다 MethodBody . (다음에서 상속됨 MethodBase) |
| GetMethodImplementationFlags() |
메서드의 구현 플래그를 반환합니다. |
| GetMethodImplementationFlags() |
파생 클래스에서 재정의되는 경우 플래그를 반환합니다 MethodImplAttributes . (다음에서 상속됨 MethodBase) |
| GetParameters() |
동적 메서드의 매개 변수를 반환합니다. |
| HasSameMetadataDefinitionAs(MemberInfo) |
컴파일, 실행 및 삭제할 수 있는 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다. (다음에서 상속됨 MemberInfo) |
| Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) |
지정된 문화권 정보와 함께 지정된 바인더의 제약 조건 하에서 지정된 매개 변수를 사용하여 동적 메서드를 호출합니다. |
| IsDefined(Type, Boolean) |
지정된 사용자 지정 특성 형식이 정의되어 있는지 여부를 나타냅니다. |
| MakeGenericMethod(Type[]) |
현재 제네릭 메서드 정의의 형식 매개 변수에 대한 형식 배열의 요소를 대체하고 생성된 생성된 메서드를 나타내는 개체를 반환 MethodInfo 합니다. (다음에서 상속됨 MethodInfo) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
문자열로 표시되는 메서드의 시그니처를 반환합니다. |
명시적 인터페이스 구현
확장명 메서드
| Name | Description |
|---|---|
| GetBaseDefinition(MethodInfo) |
컴파일, 실행 및 삭제할 수 있는 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다. |
| GetCustomAttribute(MemberInfo, Type, Boolean) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성을 검색하고 필요에 따라 해당 멤버의 상위 항목을 검사합니다. |
| GetCustomAttribute(MemberInfo, Type) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성을 검색합니다. |
| GetCustomAttribute<T>(MemberInfo, Boolean) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성을 검색하고 필요에 따라 해당 멤버의 상위 항목을 검사합니다. |
| GetCustomAttribute<T>(MemberInfo) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성을 검색합니다. |
| GetCustomAttributes(MemberInfo, Boolean) |
지정된 멤버에 적용되는 사용자 지정 특성의 컬렉션을 검색하고 필요에 따라 해당 멤버의 상위 항목을 검사합니다. |
| GetCustomAttributes(MemberInfo, Type, Boolean) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성 컬렉션을 검색하고 필요에 따라 해당 멤버의 상위 항목을 검사합니다. |
| GetCustomAttributes(MemberInfo, Type) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성 컬렉션을 검색합니다. |
| GetCustomAttributes(MemberInfo) |
지정된 멤버에 적용되는 사용자 지정 특성의 컬렉션을 검색합니다. |
| GetCustomAttributes<T>(MemberInfo, Boolean) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성 컬렉션을 검색하고 필요에 따라 해당 멤버의 상위 항목을 검사합니다. |
| GetCustomAttributes<T>(MemberInfo) |
지정된 멤버에 적용되는 지정된 형식의 사용자 지정 특성 컬렉션을 검색합니다. |
| GetMetadataToken(MemberInfo) |
사용 가능한 경우 지정된 멤버에 대한 메타데이터 토큰을 가져옵니다. |
| GetRuntimeBaseDefinition(MethodInfo) |
메서드가 처음 선언된 직접 또는 간접 기본 클래스에서 지정된 메서드를 나타내는 개체를 검색합니다. |
| HasMetadataToken(MemberInfo) |
지정된 멤버에 메타데이터 토큰을 사용할 수 있는지 여부를 나타내는 값을 반환합니다. |
| IsDefined(MemberInfo, Type, Boolean) |
지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되는지 여부와 필요에 따라 상위 항목에 적용되는지 여부를 나타냅니다. |
| IsDefined(MemberInfo, Type) |
지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되는지 여부를 나타냅니다. |