ConstructorBuilder 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義及表示動態類別的建構函式。
public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo
public ref class ConstructorBuilder abstract : System::Reflection::ConstructorInfo
public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo, System::Runtime::InteropServices::_ConstructorBuilder
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo
public abstract class ConstructorBuilder : System.Reflection.ConstructorInfo
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
type ConstructorBuilder = class
inherit ConstructorInfo
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type ConstructorBuilder = class
inherit ConstructorInfo
interface _ConstructorBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ConstructorBuilder = class
inherit ConstructorInfo
interface _ConstructorBuilder
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
Public MustInherit Class ConstructorBuilder
Inherits ConstructorInfo
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
Implements _ConstructorBuilder
- 繼承
- 屬性
- 實作
範例
下列程式代碼範例說明 的內容使用 ConstructorBuilder
方式。
using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
Type^ DynamicPointTypeGen()
{
Type^ pointType = nullptr;
array<Type^>^temp0 = {int::typeid,int::typeid,int::typeid};
array<Type^>^ctorParams = temp0;
AppDomain^ myDomain = Thread::GetDomain();
AssemblyName^ myAsmName = gcnew AssemblyName;
myAsmName->Name = "MyDynamicAssembly";
AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ pointModule = myAsmBuilder->DefineDynamicModule( "PointModule", "Point.dll" );
TypeBuilder^ pointTypeBld = pointModule->DefineType( "Point", TypeAttributes::Public );
FieldBuilder^ xField = pointTypeBld->DefineField( "x", int::typeid, FieldAttributes::Public );
FieldBuilder^ yField = pointTypeBld->DefineField( "y", int::typeid, FieldAttributes::Public );
FieldBuilder^ zField = pointTypeBld->DefineField( "z", int::typeid, FieldAttributes::Public );
Type^ objType = Type::GetType( "System.Object" );
ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array<Type^>(0) );
ConstructorBuilder^ pointCtor = pointTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams );
ILGenerator^ ctorIL = pointCtor->GetILGenerator();
// NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
// hold the actual passed parameters. ldarg.0 is used by instance methods
// to hold a reference to the current calling bject instance. Static methods
// do not use arg.0, since they are not instantiated and hence no reference
// is needed to distinguish them.
ctorIL->Emit( OpCodes::Ldarg_0 );
// Here, we wish to create an instance of System::Object by invoking its
// constructor, as specified above.
ctorIL->Emit( OpCodes::Call, objCtor );
// Now, we'll load the current instance in arg 0, along
// with the value of parameter "x" stored in arg 1, into stfld.
ctorIL->Emit( OpCodes::Ldarg_0 );
ctorIL->Emit( OpCodes::Ldarg_1 );
ctorIL->Emit( OpCodes::Stfld, xField );
// Now, we store arg 2 "y" in the current instance with stfld.
ctorIL->Emit( OpCodes::Ldarg_0 );
ctorIL->Emit( OpCodes::Ldarg_2 );
ctorIL->Emit( OpCodes::Stfld, yField );
// Last of all, arg 3 "z" gets stored in the current instance.
ctorIL->Emit( OpCodes::Ldarg_0 );
ctorIL->Emit( OpCodes::Ldarg_3 );
ctorIL->Emit( OpCodes::Stfld, zField );
// Our work complete, we return.
ctorIL->Emit( OpCodes::Ret );
// Now, let's create three very simple methods so we can see our fields.
array<String^>^temp1 = {"GetX","GetY","GetZ"};
array<String^>^mthdNames = temp1;
System::Collections::IEnumerator^ myEnum = mthdNames->GetEnumerator();
while ( myEnum->MoveNext() )
{
String^ mthdName = safe_cast<String^>(myEnum->Current);
MethodBuilder^ getFieldMthd = pointTypeBld->DefineMethod( mthdName, MethodAttributes::Public, int::typeid, nullptr );
ILGenerator^ mthdIL = getFieldMthd->GetILGenerator();
mthdIL->Emit( OpCodes::Ldarg_0 );
if ( mthdName->Equals( "GetX" ) )
mthdIL->Emit( OpCodes::Ldfld, xField );
else
if ( mthdName->Equals( "GetY" ) )
mthdIL->Emit( OpCodes::Ldfld, yField );
else
if ( mthdName->Equals( "GetZ" ) )
mthdIL->Emit( OpCodes::Ldfld, zField );
mthdIL->Emit( OpCodes::Ret );
}
pointType = pointTypeBld->CreateType();
// Let's save it, just for posterity.
myAsmBuilder->Save( "Point.dll" );
return pointType;
}
int main()
{
Type^ myDynamicType = nullptr;
Object^ aPoint = nullptr;
array<Type^>^temp2 = {int::typeid,int::typeid,int::typeid};
array<Type^>^aPtypes = temp2;
array<Object^>^temp3 = {4,5,6};
array<Object^>^aPargs = temp3;
// Call the method to build our dynamic class.
myDynamicType = DynamicPointTypeGen();
Console::WriteLine( "Some information about my new Type '{0}':", myDynamicType->FullName );
Console::WriteLine( "Assembly: '{0}'", myDynamicType->Assembly );
Console::WriteLine( "Attributes: '{0}'", myDynamicType->Attributes );
Console::WriteLine( "Module: '{0}'", myDynamicType->Module );
Console::WriteLine( "Members: " );
System::Collections::IEnumerator^ myEnum = myDynamicType->GetMembers()->GetEnumerator();
while ( myEnum->MoveNext() )
{
MemberInfo^ member = safe_cast<MemberInfo^>(myEnum->Current);
Console::WriteLine( "-- {0} {1};", member->MemberType, member->Name );
}
Console::WriteLine( "---" );
// Let's take a look at the constructor we created.
ConstructorInfo^ myDTctor = myDynamicType->GetConstructor( aPtypes );
Console::WriteLine( "Constructor: {0};", myDTctor );
Console::WriteLine( "---" );
// Now, we get to use our dynamically-created class by invoking the constructor.
aPoint = myDTctor->Invoke( aPargs );
Console::WriteLine( "aPoint is type {0}.", aPoint->GetType() );
// Finally, let's reflect on the instance of our new type - aPoint - and
// make sure everything proceeded according to plan.
Console::WriteLine( "aPoint.x = {0}", myDynamicType->InvokeMember( "GetX", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
Console::WriteLine( "aPoint.y = {0}", myDynamicType->InvokeMember( "GetY", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
Console::WriteLine( "aPoint.z = {0}", myDynamicType->InvokeMember( "GetZ", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
// +++ OUTPUT +++
// Some information about my new Type 'Point':
// Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
// Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
// Module: 'PointModule'
// Members:
// -- Field x;
// -- Field y;
// -- Field z;
// -- Method GetHashCode;
// -- Method Equals;
// -- Method ToString;
// -- Method GetType;
// -- Constructor .ctor;
// ---
// Constructor: Void .ctor(Int32, Int32, Int32);
// ---
// aPoint is type Point.
// aPoint.x = 4
// aPoint.y = 5
// aPoint.z = 6
}
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
class TestCtorBuilder {
public static Type DynamicPointTypeGen() {
Type pointType = null;
Type[] ctorParams = new Type[] {typeof(int),
typeof(int),
typeof(int)};
AppDomain myDomain = Thread.GetDomain();
AssemblyName myAsmName = new AssemblyName();
myAsmName.Name = "MyDynamicAssembly";
AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
myAsmName,
AssemblyBuilderAccess.RunAndSave);
ModuleBuilder pointModule = myAsmBuilder.DefineDynamicModule("PointModule",
"Point.dll");
TypeBuilder pointTypeBld = pointModule.DefineType("Point",
TypeAttributes.Public);
FieldBuilder xField = pointTypeBld.DefineField("x", typeof(int),
FieldAttributes.Public);
FieldBuilder yField = pointTypeBld.DefineField("y", typeof(int),
FieldAttributes.Public);
FieldBuilder zField = pointTypeBld.DefineField("z", typeof(int),
FieldAttributes.Public);
Type objType = Type.GetType("System.Object");
ConstructorInfo objCtor = objType.GetConstructor(new Type[0]);
ConstructorBuilder pointCtor = pointTypeBld.DefineConstructor(
MethodAttributes.Public,
CallingConventions.Standard,
ctorParams);
ILGenerator ctorIL = pointCtor.GetILGenerator();
// NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
// hold the actual passed parameters. ldarg.0 is used by instance methods
// to hold a reference to the current calling object instance. Static methods
// do not use arg.0, since they are not instantiated and hence no reference
// is needed to distinguish them.
ctorIL.Emit(OpCodes.Ldarg_0);
// Here, we wish to create an instance of System.Object by invoking its
// constructor, as specified above.
ctorIL.Emit(OpCodes.Call, objCtor);
// Now, we'll load the current instance ref in arg 0, along
// with the value of parameter "x" stored in arg 1, into stfld.
ctorIL.Emit(OpCodes.Ldarg_0);
ctorIL.Emit(OpCodes.Ldarg_1);
ctorIL.Emit(OpCodes.Stfld, xField);
// Now, we store arg 2 "y" in the current instance with stfld.
ctorIL.Emit(OpCodes.Ldarg_0);
ctorIL.Emit(OpCodes.Ldarg_2);
ctorIL.Emit(OpCodes.Stfld, yField);
// Last of all, arg 3 "z" gets stored in the current instance.
ctorIL.Emit(OpCodes.Ldarg_0);
ctorIL.Emit(OpCodes.Ldarg_3);
ctorIL.Emit(OpCodes.Stfld, zField);
// Our work complete, we return.
ctorIL.Emit(OpCodes.Ret);
// Now, let's create three very simple methods so we can see our fields.
string[] mthdNames = new string[] {"GetX", "GetY", "GetZ"};
foreach (string mthdName in mthdNames) {
MethodBuilder getFieldMthd = pointTypeBld.DefineMethod(
mthdName,
MethodAttributes.Public,
typeof(int),
null);
ILGenerator mthdIL = getFieldMthd.GetILGenerator();
mthdIL.Emit(OpCodes.Ldarg_0);
switch (mthdName) {
case "GetX": mthdIL.Emit(OpCodes.Ldfld, xField);
break;
case "GetY": mthdIL.Emit(OpCodes.Ldfld, yField);
break;
case "GetZ": mthdIL.Emit(OpCodes.Ldfld, zField);
break;
}
mthdIL.Emit(OpCodes.Ret);
}
// Finally, we create the type.
pointType = pointTypeBld.CreateType();
// Let's save it, just for posterity.
myAsmBuilder.Save("Point.dll");
return pointType;
}
public static void Main() {
Type myDynamicType = null;
object aPoint = null;
Type[] aPtypes = new Type[] {typeof(int), typeof(int), typeof(int)};
object[] aPargs = new object[] {4, 5, 6};
// Call the method to build our dynamic class.
myDynamicType = DynamicPointTypeGen();
Console.WriteLine("Some information about my new Type '{0}':",
myDynamicType.FullName);
Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly);
Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes);
Console.WriteLine("Module: '{0}'", myDynamicType.Module);
Console.WriteLine("Members: ");
foreach (MemberInfo member in myDynamicType.GetMembers()) {
Console.WriteLine("-- {0} {1};", member.MemberType, member.Name);
}
Console.WriteLine("---");
// Let's take a look at the constructor we created.
ConstructorInfo myDTctor = myDynamicType.GetConstructor(aPtypes);
Console.WriteLine("Constructor: {0};", myDTctor.ToString());
Console.WriteLine("---");
// Now, we get to use our dynamically-created class by invoking the constructor.
aPoint = myDTctor.Invoke(aPargs);
Console.WriteLine("aPoint is type {0}.", aPoint.GetType());
// Finally, let's reflect on the instance of our new type - aPoint - and
// make sure everything proceeded according to plan.
Console.WriteLine("aPoint.x = {0}",
myDynamicType.InvokeMember("GetX",
BindingFlags.InvokeMethod,
null,
aPoint,
new object[0]));
Console.WriteLine("aPoint.y = {0}",
myDynamicType.InvokeMember("GetY",
BindingFlags.InvokeMethod,
null,
aPoint,
new object[0]));
Console.WriteLine("aPoint.z = {0}",
myDynamicType.InvokeMember("GetZ",
BindingFlags.InvokeMethod,
null,
aPoint,
new object[0]));
// +++ OUTPUT +++
// Some information about my new Type 'Point':
// Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
// Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
// Module: 'PointModule'
// Members:
// -- Field x;
// -- Field y;
// -- Field z;
// -- Method GetHashCode;
// -- Method Equals;
// -- Method ToString;
// -- Method GetType;
// -- Constructor .ctor;
// ---
// Constructor: Void .ctor(Int32, Int32, Int32);
// ---
// aPoint is type Point.
// aPoint.x = 4
// aPoint.y = 5
// aPoint.z = 6
}
}
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit
_
Class TestCtorBuilder
Public Shared Function DynamicPointTypeGen() As Type
Dim pointType As Type = Nothing
Dim ctorParams() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
Dim myDomain As AppDomain = Thread.GetDomain()
Dim myAsmName As New AssemblyName()
myAsmName.Name = "MyDynamicAssembly"
Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.RunAndSave)
Dim pointModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule("PointModule", "Point.dll")
Dim pointTypeBld As TypeBuilder = pointModule.DefineType("Point", TypeAttributes.Public)
Dim xField As FieldBuilder = pointTypeBld.DefineField("x", GetType(Integer), FieldAttributes.Public)
Dim yField As FieldBuilder = pointTypeBld.DefineField("y", GetType(Integer), FieldAttributes.Public)
Dim zField As FieldBuilder = pointTypeBld.DefineField("z", GetType(Integer), FieldAttributes.Public)
Dim objType As Type = Type.GetType("System.Object")
Dim objCtor As ConstructorInfo = objType.GetConstructor(New Type() {})
Dim pointCtor As ConstructorBuilder = pointTypeBld.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ctorParams)
Dim ctorIL As ILGenerator = pointCtor.GetILGenerator()
' NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
' hold the actual passed parameters. ldarg.0 is used by instance methods
' to hold a reference to the current calling object instance. Static methods
' do not use arg.0, since they are not instantiated and hence no reference
' is needed to distinguish them.
ctorIL.Emit(OpCodes.Ldarg_0)
' Here, we wish to create an instance of System.Object by invoking its
' constructor, as specified above.
ctorIL.Emit(OpCodes.Call, objCtor)
' Now, we'll load the current instance ref in arg 0, along
' with the value of parameter "x" stored in arg 1, into stfld.
ctorIL.Emit(OpCodes.Ldarg_0)
ctorIL.Emit(OpCodes.Ldarg_1)
ctorIL.Emit(OpCodes.Stfld, xField)
' Now, we store arg 2 "y" in the current instance with stfld.
ctorIL.Emit(OpCodes.Ldarg_0)
ctorIL.Emit(OpCodes.Ldarg_2)
ctorIL.Emit(OpCodes.Stfld, yField)
' Last of all, arg 3 "z" gets stored in the current instance.
ctorIL.Emit(OpCodes.Ldarg_0)
ctorIL.Emit(OpCodes.Ldarg_3)
ctorIL.Emit(OpCodes.Stfld, zField)
' Our work complete, we return.
ctorIL.Emit(OpCodes.Ret)
' Now, let's create three very simple methods so we can see our fields.
Dim mthdNames() As String = {"GetX", "GetY", "GetZ"}
Dim mthdName As String
For Each mthdName In mthdNames
Dim getFieldMthd As MethodBuilder = pointTypeBld.DefineMethod(mthdName, MethodAttributes.Public, GetType(Integer), Nothing)
Dim mthdIL As ILGenerator = getFieldMthd.GetILGenerator()
mthdIL.Emit(OpCodes.Ldarg_0)
Select Case mthdName
Case "GetX"
mthdIL.Emit(OpCodes.Ldfld, xField)
Case "GetY"
mthdIL.Emit(OpCodes.Ldfld, yField)
Case "GetZ"
mthdIL.Emit(OpCodes.Ldfld, zField)
End Select
mthdIL.Emit(OpCodes.Ret)
Next mthdName
' Finally, we create the type.
pointType = pointTypeBld.CreateType()
' Let's save it, just for posterity.
myAsmBuilder.Save("Point.dll")
Return pointType
End Function 'DynamicPointTypeGen
Public Shared Sub Main()
Dim myDynamicType As Type = Nothing
Dim aPoint As Object = Nothing
Dim aPtypes() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
Dim aPargs() As Object = {4, 5, 6}
' Call the method to build our dynamic class.
myDynamicType = DynamicPointTypeGen()
Console.WriteLine("Some information about my new Type '{0}':", myDynamicType.FullName)
Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly)
Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes)
Console.WriteLine("Module: '{0}'", myDynamicType.Module)
Console.WriteLine("Members: ")
Dim member As MemberInfo
For Each member In myDynamicType.GetMembers()
Console.WriteLine("-- {0} {1};", member.MemberType, member.Name)
Next member
Console.WriteLine("---")
' Let's take a look at the constructor we created.
Dim myDTctor As ConstructorInfo = myDynamicType.GetConstructor(aPtypes)
Console.WriteLine("Constructor: {0};", myDTctor.ToString())
Console.WriteLine("---")
' Now, we get to use our dynamically-created class by invoking the constructor.
aPoint = myDTctor.Invoke(aPargs)
Console.WriteLine("aPoint is type {0}.", aPoint.GetType())
' Finally, let's reflect on the instance of our new type - aPoint - and
' make sure everything proceeded according to plan.
Console.WriteLine("aPoint.x = {0}", myDynamicType.InvokeMember("GetX", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
Console.WriteLine("aPoint.y = {0}", myDynamicType.InvokeMember("GetY", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
Console.WriteLine("aPoint.z = {0}", myDynamicType.InvokeMember("GetZ", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
End Sub
End Class
' +++ OUTPUT +++
' Some information about my new Type 'Point':
' Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
' Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
' Module: 'PointModule'
' Members:
' -- Field x;
' -- Field y;
' -- Field z;
' -- Method GetHashCode;
' -- Method Equals;
' -- Method ToString;
' -- Method GetType;
' -- Constructor .ctor;
' ---
' Constructor: Void .ctor(Int32, Int32, Int32);
' ---
' aPoint is type Point.
' aPoint.x = 4
' aPoint.y = 5
' aPoint.z = 6
備註
ConstructorBuilder 用來完整描述 Microsoft 中繼語言中的建構函式, (MSIL) ,包括名稱、屬性、簽章和建構函式主體。 它會與 類別搭配使用, TypeBuilder 以在運行時間建立類別。 呼叫 DefineConstructor 以取得的 ConstructorBuilder實例。
如果您未定義動態類型的建構函式,系統會自動提供無參數建構函式,並呼叫基類的無參數建構函式。
如果您使用 ConstructorBuilder 來定義動態類型的建構函式,則不會提供無參數建構函式。 除了您定義的建構函式之外,您還有下列選項提供無參數建構函式:
如果您想要只呼叫基類無參數建構函式的無參數建構函式,您可以使用 TypeBuilder.DefineDefaultConstructor 方法來建立一個 (,並選擇性地限制對它的存取) 。 請勿提供這個無參數建構函式的實作。 如果您這麼做,當您嘗試使用建構函式時,就會擲回例外狀況。 呼叫 方法時 TypeBuilder.CreateType 不會擲回例外狀況。
如果您想要的無參數建構函式不只是呼叫基類的無參數建構函式,或是呼叫基類的另一個建構函式,或是完全執行其他動作,您必須使用 TypeBuilder.DefineConstructor 方法來建立 ConstructorBuilder,並提供您自己的實作。
建構函式
ConstructorBuilder() |
初始化 ConstructorBuilder 類別的新執行個體。 |
屬性
Attributes |
取得這個建構函式的屬性。 |
CallingConvention |
取得 CallingConventions 值,該值取決於宣告的類型是否為泛型。 |
CallingConvention |
取得值,指出這個方法的呼叫慣例。 (繼承來源 MethodBase) |
ContainsGenericParameters |
取得值,指出泛型方法是否包含未指派的泛型型別參數。 (繼承來源 MethodBase) |
CustomAttributes |
取得包含此成員之自訂屬性的集合。 (繼承來源 MemberInfo) |
DeclaringType |
針對宣告此成員的類型,取得 Type 物件的參考。 |
InitLocals |
取得或設定這個建構函式中的本機變數是否應該以零初始化。 |
InitLocalsCore |
在衍生類別中覆寫時,取得或設定值,指出這個建構函式中的局部變數是否應該以零初始化。 |
IsAbstract |
取得值,指出方法是否為抽象。 (繼承來源 MethodBase) |
IsAssembly |
取得值,指出 Assembly 是否描述此方法或建構函式 (Constructor) 的潛在可視性;亦即,最多只有相同組件 (Assembly) 中的其他型別可以看見該方法或建構函式,組件外部的衍生型別 (Derived Type) 則看不見它們。 (繼承來源 MethodBase) |
IsCollectible |
取得指出此 MemberInfo 物件是否為可回收 AssemblyLoadContext 中保存之組件一部分的值。 (繼承來源 MemberInfo) |
IsConstructedGenericMethod |
定義及表示動態類別的建構函式。 (繼承來源 MethodBase) |
IsConstructor |
取得值,指出方法是否為建構函示。 (繼承來源 MethodBase) |
IsFamily |
取得值,指出 Family 是否描述此方法或建構函式的可視性;亦即,您只能在其類別和衍生類別內看見該方法或建構函式。 (繼承來源 MethodBase) |
IsFamilyAndAssembly |
取得值,指出 FamANDAssem 是否描述此方法或建構函式的可視性;亦即,只有當該方法或建構函式位於相同的組件時,衍生類別才能呼叫它們。 (繼承來源 MethodBase) |
IsFamilyOrAssembly |
取得值,指出 FamORAssem 是否描述此方法或建構函式的潛在可視性;亦即,無論該方法或建構函式位於何處,衍生類別以及相同組件中的類別都可以呼叫它們。 (繼承來源 MethodBase) |
IsFinal |
取得值,指出這個方法是否為 |
IsGenericMethod |
取得值,指出方法是否為泛型。 (繼承來源 MethodBase) |
IsGenericMethodDefinition |
取得值,指出方法是否為泛型方法定義。 (繼承來源 MethodBase) |
IsHideBySig |
取得值,指出是否只有簽章完全一樣的同類成員隱藏於衍生類別中。 (繼承來源 MethodBase) |
IsPrivate |
取得值,指出這個成員是否為私用的 (Private)。 (繼承來源 MethodBase) |
IsPublic |
取得值,指出這是否為公用的方法。 (繼承來源 MethodBase) |
IsSecurityCritical |
取得值,這個值表示目前方法或建構函式在目前信任層級上是否為安全性關鍵或安全性安全關鍵,因而可以執行重要的作業。 (繼承來源 MethodBase) |
IsSecuritySafeCritical |
取得值,這個值表示目前方法或建構函式在目前信任層級上是否為安全性安全關鍵,也就是說,它是否可以執行重要作業並且可供透明程式碼存取。 (繼承來源 MethodBase) |
IsSecurityTransparent |
取得值,這個值表示目前方法或建構函式在目前信任層級上是否為透明,因此不得執行重要作業。 (繼承來源 MethodBase) |
IsSpecialName |
取得值,指出這個方法是否有特別的名稱。 (繼承來源 MethodBase) |
IsStatic |
取得值指出方法是否為 |
IsVirtual |
取得值指出方法是否為 |
MemberType |
取得 MemberTypes 值,表示這個成員為建構函式。 (繼承來源 ConstructorInfo) |
MetadataToken |
取得語彙基元,可識別中繼資料中的目前動態模組。 |
MetadataToken |
取得值,這個值可識別中繼資料項目。 (繼承來源 MemberInfo) |
MethodHandle |
取得方法的內部控制代碼。 使用此控制代碼來存取基礎中繼資料控制代碼。 |
MethodHandle |
取得方法內部中繼資料 (Metadata) 表示的控制代碼。 (繼承來源 MethodBase) |
MethodImplementationFlags |
取得 MethodImplAttributes 旗標,這些旗標會指定方法實作的屬性。 |
MethodImplementationFlags |
取得 MethodImplAttributes 旗標,這些旗標會指定方法實作的屬性。 (繼承來源 MethodBase) |
Module |
取得在其中定義這個建構函式的動態模組。 |
Module |
取得用於定義型別的模組,該型別宣告以目前 MemberInfo 表示的成員。 (繼承來源 MemberInfo) |
Name |
擷取這個建構函式的名稱。 |
ReflectedType |
保留從中取得這個物件的 Type 物件參考。 |
ReflectedType |
取得類別物件,是用來取得這個 |
ReturnType |
已淘汰.
取得 |
Signature |
擷取以字串格式表示的欄位簽章。 |
方法
明確介面實作
擴充方法
GetCustomAttribute(MemberInfo, Type) |
擷取指定型別的自訂屬性,此屬性套用至指定成員。 |
GetCustomAttribute(MemberInfo, Type, Boolean) |
擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。 |
GetCustomAttribute<T>(MemberInfo) |
擷取指定型別的自訂屬性,此屬性套用至指定成員。 |
GetCustomAttribute<T>(MemberInfo, Boolean) |
擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。 |
GetCustomAttributes(MemberInfo) |
擷取套用至指定成員的自訂屬性集合。 |
GetCustomAttributes(MemberInfo, Boolean) |
擷取自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。 |
GetCustomAttributes(MemberInfo, Type) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員。 |
GetCustomAttributes(MemberInfo, Type, Boolean) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。 |
GetCustomAttributes<T>(MemberInfo) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員。 |
GetCustomAttributes<T>(MemberInfo, Boolean) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。 |
IsDefined(MemberInfo, Type) |
指出是否將所指定型別的自訂屬性套用至指定的成員。 |
IsDefined(MemberInfo, Type, Boolean) |
指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。 |
GetMetadataToken(MemberInfo) |
取得指定成員的中繼資料語彙基元 (如果有)。 |
HasMetadataToken(MemberInfo) |
傳回值,指出所指定成員是否有可用的中繼資料語彙基元。 |