DynamicMethod 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義並表示一種可編譯、執行及丟棄的動態方法。 廢棄方法可用於垃圾回收。
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
- 繼承
- 屬性
範例
以下程式碼範例建立了一個動態方法,取兩個參數。 範例中會輸出一個簡單的函式主體,將第一個參數印入主控台,並使用第二個參數作為方法的回傳值。 範例完成方法的步驟是首先創建一個委託,然後以不同的參數調用該委託,最後使用Invoke方法調用動態方法。
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
public class Test
{
// Declare a delegate type that can be used to execute the completed
// dynamic method.
private delegate int HelloDelegate(string msg, int ret);
public static void Main()
{
// Create an array that specifies the types of the parameters
// of the dynamic method. This dynamic method has a String
// parameter and an Integer parameter.
Type[] helloArgs = {typeof(string), typeof(int)};
// Create a dynamic method with the name "Hello", a return type
// of Integer, and two parameters whose types are specified by
// the array helloArgs. Create the method in the module that
// defines the String class.
DynamicMethod hello = new DynamicMethod("Hello",
typeof(int),
helloArgs,
typeof(string).Module);
// Create an array that specifies the parameter types of the
// overload of Console.WriteLine to be used in Hello.
Type[] writeStringArgs = {typeof(string)};
// Get the overload of Console.WriteLine that has one
// String parameter.
MethodInfo writeString = typeof(Console).GetMethod("WriteLine",
writeStringArgs);
// Get an ILGenerator and emit a body for the dynamic method,
// using a stream size larger than the IL that will be
// emitted.
ILGenerator il = hello.GetILGenerator(256);
// Load the first argument, which is a string, onto the stack.
il.Emit(OpCodes.Ldarg_0);
// Call the overload of Console.WriteLine that prints a string.
il.EmitCall(OpCodes.Call, writeString, null);
// The Hello method returns the value of the second argument;
// to do this, load the onto the stack and return.
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Ret);
// Add parameter information to the dynamic method. (This is not
// necessary, but can be useful for debugging.) For each parameter,
// identified by position, supply the parameter attributes and a
// parameter name.
hello.DefineParameter(1, ParameterAttributes.In, "message");
hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn");
// Create a delegate that represents the dynamic method. This
// action completes the method. Any further attempts to
// change the method are ignored.
HelloDelegate hi =
(HelloDelegate) hello.CreateDelegate(typeof(HelloDelegate));
// Use the delegate to execute the dynamic method.
Console.WriteLine("\r\nUse the delegate to execute the dynamic method:");
int retval = hi("\r\nHello, World!", 42);
Console.WriteLine("Invoking delegate hi(\"Hello, World!\", 42) returned: " + retval);
// Execute it again, with different arguments.
retval = hi("\r\nHi, Mom!", 5280);
Console.WriteLine("Invoking delegate hi(\"Hi, Mom!\", 5280) returned: " + retval);
Console.WriteLine("\r\nUse the Invoke method to execute the dynamic method:");
// Create an array of arguments to use with the Invoke method.
object[] invokeArgs = {"\r\nHello, World!", 42};
// Invoke the dynamic method using the arguments. This is much
// slower than using the delegate, because you must create an
// array to contain the arguments, and value-type arguments
// must be boxed.
object objRet = hello.Invoke(null, BindingFlags.ExactBinding, null, invokeArgs, new CultureInfo("en-us"));
Console.WriteLine("hello.Invoke returned: " + objRet);
Console.WriteLine("\r\n ----- Display information about the dynamic method -----");
// Display MethodAttributes for the dynamic method, set when
// the dynamic method was created.
Console.WriteLine("\r\nMethod Attributes: {0}", hello.Attributes);
// Display the calling convention of the dynamic method, set when the
// dynamic method was created.
Console.WriteLine("\r\nCalling convention: {0}", hello.CallingConvention);
// Display the declaring type, which is always null for dynamic
// methods.
if (hello.DeclaringType == null)
{
Console.WriteLine("\r\nDeclaringType is always null for dynamic methods.");
}
else
{
Console.WriteLine("DeclaringType: {0}", hello.DeclaringType);
}
// Display the default value for InitLocals.
if (hello.InitLocals)
{
Console.Write("\r\nThis method contains verifiable code.");
}
else
{
Console.Write("\r\nThis method contains unverifiable code.");
}
Console.WriteLine(" (InitLocals = {0})", hello.InitLocals);
// Display the module specified when the dynamic method was created.
Console.WriteLine("\r\nModule: {0}", hello.Module);
// Display the name specified when the dynamic method was created.
// Note that the name can be blank.
Console.WriteLine("\r\nName: {0}", hello.Name);
// For dynamic methods, the reflected type is always null.
if (hello.ReflectedType == null)
{
Console.WriteLine("\r\nReflectedType is null.");
}
else
{
Console.WriteLine("\r\nReflectedType: {0}", hello.ReflectedType);
}
if (hello.ReturnParameter == null)
{
Console.WriteLine("\r\nMethod has no return parameter.");
}
else
{
Console.WriteLine("\r\nReturn parameter: {0}", hello.ReturnParameter);
}
// If the method has no return type, ReturnType is System.Void.
Console.WriteLine("\r\nReturn type: {0}", hello.ReturnType);
// ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
// that can be used to enumerate the custom attributes of the
// return value. At present, there is no way to set such custom
// attributes, so the list is empty.
if (hello.ReturnType == typeof(void))
{
Console.WriteLine("The method has no return type.");
}
else
{
ICustomAttributeProvider caProvider = hello.ReturnTypeCustomAttributes;
object[] returnAttributes = caProvider.GetCustomAttributes(true);
if (returnAttributes.Length == 0)
{
Console.WriteLine("\r\nThe return type has no custom attributes.");
}
else
{
Console.WriteLine("\r\nThe return type has the following custom attributes:");
foreach( object attr in returnAttributes )
{
Console.WriteLine("\t{0}", attr.ToString());
}
}
}
Console.WriteLine("\r\nToString: {0}", hello.ToString());
// Display parameter information.
ParameterInfo[] parameters = hello.GetParameters();
Console.WriteLine("\r\nParameters: name, type, ParameterAttributes");
foreach( ParameterInfo p in parameters )
{
Console.WriteLine("\t{0}, {1}, {2}",
p.Name, p.ParameterType, p.Attributes);
}
}
}
/* This code example produces the following output:
Use the delegate to execute the dynamic method:
Hello, World!
Invoking delegate hi("Hello, World!", 42) returned: 42
Hi, Mom!
Invoking delegate hi("Hi, Mom!", 5280) returned: 5280
Use the Invoke method to execute the dynamic method:
Hello, World!
hello.Invoke returned: 42
----- Display information about the dynamic method -----
Method Attributes: PrivateScope, Public, Static
Calling convention: Standard
DeclaringType is always null for dynamic methods.
This method contains verifiable code. (InitLocals = True)
Module: CommonLanguageRuntimeLibrary
Name: Hello
ReflectedType is null.
Method has no return parameter.
Return type: System.Int32
The return type has no custom attributes.
ToString: Int32 Hello(System.String, Int32)
Parameters: name, type, ParameterAttributes
message, System.String, In
valueToReturn, System.Int32, In
*/
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Globalization
Public Class Test
' Declare a delegate type that can be used to execute the completed
' dynamic method.
Private Delegate Function HelloDelegate(ByVal msg As String, _
ByVal ret As Integer) As Integer
Public Shared Sub Main()
' Create an array that specifies the types of the parameters
' of the dynamic method. This dynamic method has a String
' parameter and an Integer parameter.
Dim helloArgs() As Type = {GetType(String), GetType(Integer)}
' Create a dynamic method with the name "Hello", a return type
' of Integer, and two parameters whose types are specified by
' the array helloArgs. Create the method in the module that
' defines the String class.
Dim hello As New DynamicMethod("Hello", _
GetType(Integer), _
helloArgs, _
GetType(String).Module)
' Create an array that specifies the parameter types of the
' overload of Console.WriteLine to be used in Hello.
Dim writeStringArgs() As Type = {GetType(String)}
' Get the overload of Console.WriteLine that has one
' String parameter.
Dim writeString As MethodInfo = GetType(Console). _
GetMethod("WriteLine", writeStringArgs)
' Get an ILGenerator and emit a body for the dynamic method,
' using a stream size larger than the IL that will be
' emitted.
Dim il As ILGenerator = hello.GetILGenerator(256)
' Load the first argument, which is a string, onto the stack.
il.Emit(OpCodes.Ldarg_0)
' Call the overload of Console.WriteLine that prints a string.
il.EmitCall(OpCodes.Call, writeString, Nothing)
' The Hello method returns the value of the second argument;
' to do this, load the onto the stack and return.
il.Emit(OpCodes.Ldarg_1)
il.Emit(OpCodes.Ret)
' Add parameter information to the dynamic method. (This is not
' necessary, but can be useful for debugging.) For each parameter,
' identified by position, supply the parameter attributes and a
' parameter name.
hello.DefineParameter(1, ParameterAttributes.In, "message")
hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn")
' Create a delegate that represents the dynamic method. This
' action completes the method. Any further attempts to
' change the method are ignored.
Dim hi As HelloDelegate = _
CType(hello.CreateDelegate(GetType(HelloDelegate)), HelloDelegate)
' Use the delegate to execute the dynamic method.
Console.WriteLine(vbCrLf & "Use the delegate to execute the dynamic method:")
Dim retval As Integer = hi(vbCrLf & "Hello, World!", 42)
Console.WriteLine("Invoking delegate hi(""Hello, World!"", 42) returned: " _
& retval & ".")
' Execute it again, with different arguments.
retval = hi(vbCrLf & "Hi, Mom!", 5280)
Console.WriteLine("Invoking delegate hi(""Hi, Mom!"", 5280) returned: " _
& retval & ".")
Console.WriteLine(vbCrLf & "Use the Invoke method to execute the dynamic method:")
' Create an array of arguments to use with the Invoke method.
Dim invokeArgs() As Object = {vbCrLf & "Hello, World!", 42}
' Invoke the dynamic method using the arguments. This is much
' slower than using the delegate, because you must create an
' array to contain the arguments, and value-type arguments
' must be boxed.
Dim objRet As Object = hello.Invoke(Nothing, _
BindingFlags.ExactBinding, Nothing, invokeArgs, _
New CultureInfo("en-us"))
Console.WriteLine("hello.Invoke returned: {0}", objRet)
Console.WriteLine(vbCrLf & _
" ----- Display information about the dynamic method -----")
' Display MethodAttributes for the dynamic method, set when
' the dynamic method was created.
Console.WriteLine(vbCrLf & "Method Attributes: {0}", _
hello.Attributes)
' Display the calling convention of the dynamic method, set when the
' dynamic method was created.
Console.WriteLine(vbCrLf & "Calling convention: {0}", _
hello.CallingConvention)
' Display the declaring type, which is always Nothing for dynamic
' methods.
If hello.DeclaringType Is Nothing Then
Console.WriteLine(vbCrLf & "DeclaringType is always Nothing for dynamic methods.")
Else
Console.WriteLine("DeclaringType: {0}", hello.DeclaringType)
End If
' Display the default value for InitLocals.
If hello.InitLocals Then
Console.Write(vbCrLf & "This method contains verifiable code.")
Else
Console.Write(vbCrLf & "This method contains unverifiable code.")
End If
Console.WriteLine(" (InitLocals = {0})", hello.InitLocals)
' Display the module specified when the dynamic method was created.
Console.WriteLine(vbCrLf & "Module: {0}", hello.Module)
' Display the name specified when the dynamic method was created.
' Note that the name can be blank.
Console.WriteLine(vbCrLf & "Name: {0}", hello.Name)
' For dynamic methods, the reflected type is always Nothing.
If hello.ReflectedType Is Nothing Then
Console.WriteLine(vbCrLf & "ReflectedType is Nothing.")
Else
Console.WriteLine(vbCrLf & "ReflectedType: {0}", _
hello.ReflectedType)
End If
If hello.ReturnParameter Is Nothing Then
Console.WriteLine(vbCrLf & "Method has no return parameter.")
Else
Console.WriteLine(vbCrLf & "Return parameter: {0}", _
hello.ReturnParameter)
End If
' If the method has no return type, ReturnType is System.Void.
Console.WriteLine(vbCrLf & "Return type: {0}", hello.ReturnType)
' ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
' that can be used to enumerate the custom attributes of the
' return value. At present, there is no way to set such custom
' attributes, so the list is empty.
If hello.ReturnType Is GetType(System.Void) Then
Console.WriteLine("The method has no return type.")
Else
Dim caProvider As ICustomAttributeProvider = _
hello.ReturnTypeCustomAttributes
Dim returnAttributes() As Object = _
caProvider.GetCustomAttributes(True)
If returnAttributes.Length = 0 Then
Console.WriteLine(vbCrLf _
& "The return type has no custom attributes.")
Else
Console.WriteLine(vbCrLf _
& "The return type has the following custom attributes:")
For Each attr As Object In returnAttributes
Console.WriteLine(vbTab & attr.ToString())
Next attr
End If
End If
Console.WriteLine(vbCrLf & "ToString: " & hello.ToString())
' Display parameter information.
Dim parameters() As ParameterInfo = hello.GetParameters()
Console.WriteLine(vbCrLf & "Parameters: name, type, ParameterAttributes")
For Each p As ParameterInfo In parameters
Console.WriteLine(vbTab & "{0}, {1}, {2}", _
p.Name, p.ParameterType, p.Attributes)
Next p
End Sub
End Class
' This code example produces the following output:
'
'Use the delegate to execute the dynamic method:
'
'Hello, World!
'Invoking delegate hi("Hello, World!", 42) returned: 42.
'
'Hi, Mom!
'Invoking delegate hi("Hi, Mom!", 5280) returned: 5280.
'
'Use the Invoke method to execute the dynamic method:
'
'Hello, World!
'hello.Invoke returned: 42
'
' ----- Display information about the dynamic method -----
'
'Method Attributes: PrivateScope, Public, Static
'
'Calling convention: Standard
'
'DeclaringType is always Nothing for dynamic methods.
'
'This method contains verifiable code. (InitLocals = True)
'
'Module: CommonLanguageRuntimeLibrary
'
'Name: Hello
'
'ReflectedType is Nothing.
'
'Method has no return parameter.
'
'Return type: System.Int32
'
'The return type has no custom attributes.
'
'ToString: Int32 Hello(System.String, Int32)
'
'Parameters: name, type, ParameterAttributes
' message, System.String, In
' valueToReturn, System.Int32, In
備註
欲了解更多關於此 API 的資訊,請參閱 DynamicMethod 的補充 API 備註。
建構函式
| 名稱 | Description |
|---|---|
| DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean) |
建立一個全域於模組的動態方法,指定方法名稱、屬性、呼叫慣例、回傳型別、參數類型、模組,以及是否應跳過動態方法的 Microsoft 中介語言(MSIL)存取的型別與成員的即時(JIT)可見性檢查。 |
| DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type, Boolean) |
建立動態方法,指定方法名稱、屬性、呼叫慣例、回傳型別、參數型別、動態方法邏輯關聯的型別,以及是否應跳過動態方法Microsoft中介語言(MSIL)存取的型別與成員的即時(JIT)可見性檢查。 |
| DynamicMethod(String, Type, Type[], Boolean) |
初始化一個匿名託管的動態方法,指定方法名稱、回傳類型、參數類型,以及是否應跳過動態方法的 Microsoft 中介語言(MSIL)存取的型別與成員的即時(JIT)可見性檢查。 |
| DynamicMethod(String, Type, Type[], Module, Boolean) |
建立一個全域於模組的動態方法,指定方法名稱、回傳類型、參數類型、模組,以及是否應跳過動態方法的 Microsoft 中介語言(MSIL)存取的型別與成員的即時(JIT)可見性檢查。 |
| DynamicMethod(String, Type, Type[], Module) |
建立一個動態方法,該方法對模組為全域,指定方法名稱、回傳類型、參數類型及模組。 |
| DynamicMethod(String, Type, Type[], Type, Boolean) |
建立一個動態方法,指定方法名稱、回傳類型、參數類型、動態方法邏輯關聯的類型,以及是否應跳過動態方法的 Microsoft 中介語言(MSIL)存取的即時(JIT)可見性檢查。 |
| DynamicMethod(String, Type, Type[], Type) |
建立一個動態方法,指定方法名稱、回傳類型、參數類型,以及動態方法邏輯關聯的類型。 |
| DynamicMethod(String, Type, Type[]) |
初始化一個匿名託管的動態方法,指定方法名稱、回傳類型及參數類型。 |
屬性
| 名稱 | Description |
|---|---|
| Attributes |
取得動態方法建立時指定的屬性。 |
| CallingConvention |
取得動態方法建立時指定的呼叫慣例。 |
| ContainsGenericParameters |
會得到一個值,表示某個通用方法是否包含未指派的通用型別參數。 (繼承來源 MethodInfo) |
| CustomAttributes |
會獲得包含該成員自訂屬性的集合。 (繼承來源 MemberInfo) |
| DeclaringType |
取得宣告該方法的型別,而該方法總是 |
| InitLocals |
取得或設定一個值,表示方法中的局部變數是否為零初始化。 |
| IsAbstract |
會得到一個值,表示該方法是否為抽象。 (繼承來源 MethodBase) |
| IsAssembly |
獲得一個值,表示此方法或建構子的潛在可見性是否由 Assembly描述;也就是說,該方法或建構器最多對同一組裝中的其他型別可見,對組裝外的衍生型別則無法看到。 (繼承來源 MethodBase) |
| IsConstructedGenericMethod |
定義並表示一種可編譯、執行及丟棄的動態方法。 廢棄方法可用於垃圾回收。 (繼承來源 MethodBase) |
| IsConstructor |
會得到一個值,表示該方法是否為建構子。 (繼承來源 MethodBase) |
| IsFamily |
獲得一個值,表示此方法或建構子的可見性是否由 Family描述;也就是說,該方法或建構子僅在其類別及其衍生類別中可見。 (繼承來源 MethodBase) |
| IsFamilyAndAssembly |
會得到一個值,表示此方法或建構子的可見性是否由 FamANDAssem描述;也就是說,該方法或建構子可以被導出類別呼叫,但前提是它們位於同一組建構中。 (繼承來源 MethodBase) |
| IsFamilyOrAssembly |
會得到一個值,表示此方法或建構子的潛在可見性是否由 FamORAssem描述;也就是說,該方法或建構子可以被派生類別呼叫,無論它們所在的位置,或同一組合語言中的類別。 (繼承來源 MethodBase) |
| IsFinal |
得到一個值,表示此方法是否為 |
| IsGenericMethod |
會得到一個值,表示目前的方法是否屬於通用方法。 (繼承來源 MethodInfo) |
| IsGenericMethodDefinition |
會得到一個值,表示電流 MethodInfo 是否代表一般方法的定義。 (繼承來源 MethodInfo) |
| IsHideBySig |
會得到一個值,表示導出類別中是否只有同類型且簽名完全相同的成員被隱藏。 (繼承來源 MethodBase) |
| IsPrivate |
會獲得一個值,表示該成員是否為私人。 (繼承來源 MethodBase) |
| IsPublic |
會有一個值來表示這是否是一個公開方法。 (繼承來源 MethodBase) |
| IsSecurityCritical |
獲得一個值,表示目前動態方法是安全關鍵還是安全安全關鍵,因此能執行關鍵操作。 |
| IsSecurityCritical |
會獲得一個值,表示目前的方法或建構子在當前信任層級下是安全關鍵還是安全關鍵,因此可以執行關鍵操作。 (繼承來源 MethodBase) |
| IsSecuritySafeCritical |
獲得一個值,表示目前動態方法在當前信任層級是否為安全關鍵;也就是說,它是否能執行關鍵操作,且是否能被透明程式碼存取。 |
| IsSecuritySafeCritical |
獲得一個值,表示目前的方法或建構子在當前信任層級是否為安全關鍵;也就是說,它是否能執行關鍵操作,且是否能被透明程式碼存取。 (繼承來源 MethodBase) |
| IsSecurityTransparent |
會得到一個值,表示目前動態方法在信任層級是否透明,因此無法執行關鍵操作。 |
| IsSecurityTransparent |
會獲得一個值,表示目前的方法或建構子在目前信任層級是否透明,因此無法執行關鍵操作。 (繼承來源 MethodBase) |
| IsSpecialName |
會得到一個值,表示此方法是否有特殊名稱。 (繼承來源 MethodBase) |
| IsStatic |
獲得一個值,表示該方法是否為 |
| IsVirtual |
獲得一個值,表示該方法是否為 |
| MemberType |
會得到 MemberTypes 一個值,表示該成員是一個方法。 (繼承來源 MethodInfo) |
| MetadataToken |
會得到一個識別元資料元素的值。 (繼承來源 MemberInfo) |
| MethodHandle |
不支援動態方法。 |
| MethodImplementationFlags |
取得 MethodImplAttributes 指定方法實作屬性的旗標。 (繼承來源 MethodBase) |
| Module |
取得動態方法邏輯關聯的模組。 |
| Module |
取得定義宣告電流所代表 MemberInfo 成員型態的模組。 (繼承來源 MemberInfo) |
| Name |
得到動態方法的名稱。 |
| ReflectedType |
取得在 Reflection 中用來取得該方法的類別。 |
| ReturnParameter |
取得動態方法的回傳參數。 |
| ReturnType |
取得動態方法的回傳值類型。 |
| ReturnTypeCustomAttributes |
取得動態方法返回類型的自訂屬性。 |
方法
| 名稱 | Description |
|---|---|
| CreateDelegate(Type, Object) |
完成動態方法並建立一個代理,可用於執行,指定代理類型及代理綁定的物件。 |
| CreateDelegate(Type) |
完成動態方法並建立一個代理來執行。 |
| DefineParameter(Int32, ParameterAttributes, String) |
定義動態方法的參數。 |
| Equals(Object) |
傳回值,這個值表示這個實例是否等於指定的物件。 (繼承來源 MethodInfo) |
| GetBaseDefinition() |
回傳方法的基礎實作。 |
| GetCustomAttributes(Boolean) |
會回傳所有為該方法定義的自訂屬性。 |
| GetCustomAttributes(Type, Boolean) |
回傳已套用到方法的指定類型自訂屬性。 |
| GetCustomAttributesData() |
回傳一份物件清單 CustomAttributeData ,代表已套用於目標成員的屬性資料。 (繼承來源 MemberInfo) |
| GetDynamicILInfo() |
回傳一個 DynamicILInfo 物件,可用於從元資料標記、作用域及Microsoft中介語言(MSIL)串流中產生方法主體。 |
| GetGenericArguments() |
回傳一個物件陣列 Type ,代表一般方法的型別參數或一般方法定義的型別參數。 (繼承來源 MethodInfo) |
| GetGenericMethodDefinition() |
回傳一個 MethodInfo 代表通用方法定義的物件,可用來構建目前的方法。 (繼承來源 MethodInfo) |
| GetHashCode() |
傳回這個實例的哈希碼。 (繼承來源 MethodInfo) |
| GetILGenerator() |
回傳一個 Microsoft 中介語言(MSIL)產生器,預設 MSIL 串流大小為 64 位元組。 |
| GetILGenerator(Int32) |
回傳一個 Microsoft 中介語言(MSIL)產生器,該方法具有指定的 MSIL 串流大小。 |
| GetMethodBody() |
當在衍生類別中覆寫時,會獲得 MethodBody 一個物件,提供存取 MSIL 串流、本地變數及當前方法例外的存取權。 (繼承來源 MethodBase) |
| GetMethodImplementationFlags() |
回傳方法的實作旗標。 |
| GetParameters() |
回傳動態方法的參數。 |
| HasSameMetadataDefinitionAs(MemberInfo) |
定義並表示一種可編譯、執行及丟棄的動態方法。 廢棄方法可用於垃圾回收。 (繼承來源 MemberInfo) |
| Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) |
在指定的結合器限制下,使用指定的參數呼叫動態方法,並取得指定的培養資訊。 |
| IsDefined(Type, Boolean) |
表示是否定義了指定的自訂屬性類型。 |
| MakeGenericMethod(Type[]) |
將型別陣列中的元素替換為目前通用方法定義的型別參數,並回傳 MethodInfo 一個代表所建構方法的物件。 (繼承來源 MethodInfo) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
回傳方法的簽名,以字串表示。 |
明確介面實作
擴充方法
| 名稱 | Description |
|---|---|
| GetCustomAttribute(MemberInfo, Type, Boolean) |
擷取指定類型的自訂屬性,套用於指定成員,並可選擇性地檢查該成員的祖先。 |
| GetCustomAttribute(MemberInfo, Type) |
擷取指定型別的自訂屬性,套用到指定成員。 |
| GetCustomAttribute<T>(MemberInfo, Boolean) |
擷取指定類型的自訂屬性,套用於指定成員,並可選擇性地檢查該成員的祖先。 |
| GetCustomAttribute<T>(MemberInfo) |
擷取指定型別的自訂屬性,套用到指定成員。 |
| GetCustomAttributes(MemberInfo, Boolean) |
擷取一套套用於指定成員的自訂屬性,並可選擇性地檢查該成員的祖先。 |
| GetCustomAttributes(MemberInfo, Type, Boolean) |
擷取一組指定類型的自訂屬性,套用於指定成員,並可選擇性檢查該成員的祖先。 |
| GetCustomAttributes(MemberInfo, Type) |
擷取一組指定類型的自訂屬性,套用到指定成員。 |
| GetCustomAttributes(MemberInfo) |
擷取一套套用於指定成員的自訂屬性集合。 |
| GetCustomAttributes<T>(MemberInfo, Boolean) |
擷取一組指定類型的自訂屬性,套用於指定成員,並可選擇性檢查該成員的祖先。 |
| GetCustomAttributes<T>(MemberInfo) |
擷取一組指定類型的自訂屬性,套用到指定成員。 |
| GetRuntimeBaseDefinition(MethodInfo) |
擷取代表指定方法的物件,該物件在直接或間接基底類別中,該方法首次宣告該類別。 |
| IsDefined(MemberInfo, Type, Boolean) |
表示是否將特定類型的自訂屬性套用於指定成員,並可選擇套用於其祖先。 |
| IsDefined(MemberInfo, Type) |
表示是否套用特定類型的自訂屬性給指定成員。 |