PropertyBuilder 類別

定義

定義型別的屬性。

public ref class PropertyBuilder sealed : System::Reflection::PropertyInfo
public ref class PropertyBuilder abstract : System::Reflection::PropertyInfo
public ref class PropertyBuilder sealed : System::Reflection::PropertyInfo, System::Runtime::InteropServices::_PropertyBuilder
public sealed class PropertyBuilder : System.Reflection.PropertyInfo
public abstract class PropertyBuilder : System.Reflection.PropertyInfo
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class PropertyBuilder : System.Reflection.PropertyInfo, System.Runtime.InteropServices._PropertyBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class PropertyBuilder : System.Reflection.PropertyInfo, System.Runtime.InteropServices._PropertyBuilder
type PropertyBuilder = class
    inherit PropertyInfo
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type PropertyBuilder = class
    inherit PropertyInfo
    interface _PropertyBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type PropertyBuilder = class
    inherit PropertyInfo
    interface _PropertyBuilder
Public NotInheritable Class PropertyBuilder
Inherits PropertyInfo
Public MustInherit Class PropertyBuilder
Inherits PropertyInfo
Public NotInheritable Class PropertyBuilder
Inherits PropertyInfo
Implements _PropertyBuilder
繼承
PropertyBuilder
屬性
實作

範例

下列程式代碼範例示範如何使用 透過 取得TypeBuilder.DefineProperty的 ,PropertyBuilder在動態類型中實作屬性,以建立屬性架構和相關聯的 MethodBuilder ,以在屬性內實作 IL 邏輯。

using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
Type^ BuildDynamicTypeWithProperties()
{
   AppDomain^ myDomain = Thread::GetDomain();
   AssemblyName^ myAsmName = gcnew AssemblyName;
   myAsmName->Name = "MyDynamicAssembly";
   
   // To generate a persistable assembly, specify AssemblyBuilderAccess::RunAndSave.
   AssemblyBuilder^ myAsmBuilder = 
       myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave );
   
   // Generate a persistable single-module assembly.
   ModuleBuilder^ myModBuilder = 
       myAsmBuilder->DefineDynamicModule( myAsmName->Name, myAsmName->Name + ".dll" );
   TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "CustomerData", TypeAttributes::Public );

   // Define a private field to hold the property value.
   FieldBuilder^ customerNameBldr = myTypeBuilder->DefineField( "customerName", String::typeid, FieldAttributes::Private );
   
   // The last argument of DefineProperty is an empty array of Type
   // objects, because the property has no parameters. (Alternatively,
   // you can specify a null value.)
   PropertyBuilder^ custNamePropBldr = 
       myTypeBuilder->DefineProperty( "CustomerName", PropertyAttributes::HasDefault, String::typeid, gcnew array<Type^>(0) );
   
   // The property set and property get methods require a special
   // set of attributes.
   MethodAttributes getSetAttr = 
       MethodAttributes::Public | MethodAttributes::SpecialName |
           MethodAttributes::HideBySig;

   // Define the "get" accessor method for CustomerName.
   MethodBuilder^ custNameGetPropMthdBldr = 
       myTypeBuilder->DefineMethod( "get_CustomerName", 
                                    getSetAttr,
                                    String::typeid, 
                                    Type::EmptyTypes );

   ILGenerator^ custNameGetIL = custNameGetPropMthdBldr->GetILGenerator();
   custNameGetIL->Emit( OpCodes::Ldarg_0 );
   custNameGetIL->Emit( OpCodes::Ldfld, customerNameBldr );
   custNameGetIL->Emit( OpCodes::Ret );
   
   // Define the "set" accessor method for CustomerName.
   array<Type^>^temp2 = {String::typeid};
   MethodBuilder^ custNameSetPropMthdBldr = 
       myTypeBuilder->DefineMethod( "set_CustomerName", 
                                    getSetAttr,
                                    nullptr, 
                                    temp2 );

   ILGenerator^ custNameSetIL = custNameSetPropMthdBldr->GetILGenerator();
   custNameSetIL->Emit( OpCodes::Ldarg_0 );
   custNameSetIL->Emit( OpCodes::Ldarg_1 );
   custNameSetIL->Emit( OpCodes::Stfld, customerNameBldr );
   custNameSetIL->Emit( OpCodes::Ret );
   
   // Last, we must map the two methods created above to our PropertyBuilder to
   // their corresponding behaviors, "get" and "set" respectively.
   custNamePropBldr->SetGetMethod( custNameGetPropMthdBldr );
   custNamePropBldr->SetSetMethod( custNameSetPropMthdBldr );

   Type^ retval = myTypeBuilder->CreateType();

   // Save the assembly so it can be examined with Ildasm.exe,
   // or referenced by a test program.
   myAsmBuilder->Save(myAsmName->Name + ".dll");
   return retval;
}

int main()
{
   Type^ custDataType = BuildDynamicTypeWithProperties();
   array<PropertyInfo^>^custDataPropInfo = custDataType->GetProperties();
   System::Collections::IEnumerator^ myEnum = custDataPropInfo->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      PropertyInfo^ pInfo = safe_cast<PropertyInfo^>(myEnum->Current);
      Console::WriteLine( "Property '{0}' created!", pInfo );
   }

   Console::WriteLine( "---" );
   
   // Note that when invoking a property, you need to use the proper BindingFlags -
   // BindingFlags::SetProperty when you invoke the "set" behavior, and
   // BindingFlags::GetProperty when you invoke the "get" behavior. Also note that
   // we invoke them based on the name we gave the property, as expected, and not
   // the name of the methods we bound to the specific property behaviors.
   Object^ custData = Activator::CreateInstance( custDataType );
   array<Object^>^temp3 = {"Joe User"};
   custDataType->InvokeMember( "CustomerName", BindingFlags::SetProperty, nullptr, custData, temp3 );
   Console::WriteLine( "The customerName field of instance custData has been set to '{0}'.", custDataType->InvokeMember( "CustomerName", BindingFlags::GetProperty, nullptr, custData, gcnew array<Object^>(0) ) );
}

// --- O U T P U T ---
// The output should be as follows:
// -------------------
// Property 'System.String CustomerName' created!
// ---
// The customerName field of instance custData has been set to 'Joe User'.
// -------------------
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

class PropertyBuilderDemo
{
   public static Type BuildDynamicTypeWithProperties()
   {
        AppDomain myDomain = Thread.GetDomain();
        AssemblyName myAsmName = new AssemblyName();
        myAsmName.Name = "MyDynamicAssembly";

        // To generate a persistable assembly, specify AssemblyBuilderAccess.RunAndSave.
        AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(myAsmName,
                                                        AssemblyBuilderAccess.RunAndSave);
        // Generate a persistable single-module assembly.
        ModuleBuilder myModBuilder =
            myAsmBuilder.DefineDynamicModule(myAsmName.Name, myAsmName.Name + ".dll");

        TypeBuilder myTypeBuilder = myModBuilder.DefineType("CustomerData",
                                                        TypeAttributes.Public);

        FieldBuilder customerNameBldr = myTypeBuilder.DefineField("customerName",
                                                        typeof(string),
                                                        FieldAttributes.Private);

        // The last argument of DefineProperty is null, because the
        // property has no parameters. (If you don't specify null, you must
        // specify an array of Type objects. For a parameterless property,
        // use an array with no elements: new Type[] {})
        PropertyBuilder custNamePropBldr = myTypeBuilder.DefineProperty("CustomerName",
                                                         PropertyAttributes.HasDefault,
                                                         typeof(string),
                                                         null);

        // The property set and property get methods require a special
        // set of attributes.
        MethodAttributes getSetAttr =
            MethodAttributes.Public | MethodAttributes.SpecialName |
                MethodAttributes.HideBySig;

        // Define the "get" accessor method for CustomerName.
        MethodBuilder custNameGetPropMthdBldr =
            myTypeBuilder.DefineMethod("get_CustomerName",
                                       getSetAttr,
                                       typeof(string),
                                       Type.EmptyTypes);

        ILGenerator custNameGetIL = custNameGetPropMthdBldr.GetILGenerator();

        custNameGetIL.Emit(OpCodes.Ldarg_0);
        custNameGetIL.Emit(OpCodes.Ldfld, customerNameBldr);
        custNameGetIL.Emit(OpCodes.Ret);

        // Define the "set" accessor method for CustomerName.
        MethodBuilder custNameSetPropMthdBldr =
            myTypeBuilder.DefineMethod("set_CustomerName",
                                       getSetAttr,
                                       null,
                                       new Type[] { typeof(string) });

        ILGenerator custNameSetIL = custNameSetPropMthdBldr.GetILGenerator();

        custNameSetIL.Emit(OpCodes.Ldarg_0);
        custNameSetIL.Emit(OpCodes.Ldarg_1);
        custNameSetIL.Emit(OpCodes.Stfld, customerNameBldr);
        custNameSetIL.Emit(OpCodes.Ret);

        // Last, we must map the two methods created above to our PropertyBuilder to
        // their corresponding behaviors, "get" and "set" respectively.
        custNamePropBldr.SetGetMethod(custNameGetPropMthdBldr);
        custNamePropBldr.SetSetMethod(custNameSetPropMthdBldr);

        Type retval = myTypeBuilder.CreateType();

        // Save the assembly so it can be examined with Ildasm.exe,
        // or referenced by a test program.
        myAsmBuilder.Save(myAsmName.Name + ".dll");
        return retval;
   }

   public static void Main()
   {
        Type custDataType = BuildDynamicTypeWithProperties();

        PropertyInfo[] custDataPropInfo = custDataType.GetProperties();
        foreach (PropertyInfo pInfo in custDataPropInfo) {
           Console.WriteLine("Property '{0}' created!", pInfo.ToString());
        }

        Console.WriteLine("---");
        // Note that when invoking a property, you need to use the proper BindingFlags -
        // BindingFlags.SetProperty when you invoke the "set" behavior, and
        // BindingFlags.GetProperty when you invoke the "get" behavior. Also note that
        // we invoke them based on the name we gave the property, as expected, and not
        // the name of the methods we bound to the specific property behaviors.

        object custData = Activator.CreateInstance(custDataType);
        custDataType.InvokeMember("CustomerName", BindingFlags.SetProperty,
                                      null, custData, new object[]{ "Joe User" });

        Console.WriteLine("The customerName field of instance custData has been set to '{0}'.",
                           custDataType.InvokeMember("CustomerName", BindingFlags.GetProperty,
                                                      null, custData, new object[]{ }));
   }
}

// --- O U T P U T ---
// The output should be as follows:
// -------------------
// Property 'System.String CustomerName' created!
// ---
// The customerName field of instance custData has been set to 'Joe User'.
// -------------------
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

Class PropertyBuilderDemo
   
   Public Shared Function BuildDynamicTypeWithProperties() As Type
      Dim myDomain As AppDomain = Thread.GetDomain()
      Dim myAsmName As New AssemblyName()
      myAsmName.Name = "MyDynamicAssembly"
      
      ' To generate a persistable assembly, specify AssemblyBuilderAccess.RunAndSave.
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, _
                                                        AssemblyBuilderAccess.RunAndSave)
      
      ' Generate a persistable, single-module assembly.
      Dim myModBuilder As ModuleBuilder = _
          myAsmBuilder.DefineDynamicModule(myAsmName.Name, myAsmName.Name & ".dll")
      
      Dim myTypeBuilder As TypeBuilder = myModBuilder.DefineType("CustomerData", TypeAttributes.Public)
      
      ' Define a private field to hold the property value.
      Dim customerNameBldr As FieldBuilder = myTypeBuilder.DefineField("customerName", _
                                             GetType(String), FieldAttributes.Private)
      
      ' The last argument of DefineProperty is Nothing, because the
      ' property has no parameters. (If you don't specify Nothing, you must
      ' specify an array of Type objects. For a parameterless property,
      ' use an array with no elements: New Type() {})
      Dim custNamePropBldr As PropertyBuilder = _
          myTypeBuilder.DefineProperty("CustomerName", _
                                       PropertyAttributes.HasDefault, _
                                       GetType(String), _
                                       Nothing)
      
      ' The property set and property get methods require a special
      ' set of attributes.
      Dim getSetAttr As MethodAttributes = _
          MethodAttributes.Public Or MethodAttributes.SpecialName _
              Or MethodAttributes.HideBySig

      ' Define the "get" accessor method for CustomerName.
      Dim custNameGetPropMthdBldr As MethodBuilder = _
          myTypeBuilder.DefineMethod("GetCustomerName", _
                                     getSetAttr, _
                                     GetType(String), _
                                     Type.EmptyTypes)
      
      Dim custNameGetIL As ILGenerator = custNameGetPropMthdBldr.GetILGenerator()
      
      custNameGetIL.Emit(OpCodes.Ldarg_0)
      custNameGetIL.Emit(OpCodes.Ldfld, customerNameBldr)
      custNameGetIL.Emit(OpCodes.Ret)
      
      ' Define the "set" accessor method for CustomerName.
      Dim custNameSetPropMthdBldr As MethodBuilder = _
          myTypeBuilder.DefineMethod("get_CustomerName", _
                                     getSetAttr, _
                                     Nothing, _
                                     New Type() {GetType(String)})
      
      Dim custNameSetIL As ILGenerator = custNameSetPropMthdBldr.GetILGenerator()
      
      custNameSetIL.Emit(OpCodes.Ldarg_0)
      custNameSetIL.Emit(OpCodes.Ldarg_1)
      custNameSetIL.Emit(OpCodes.Stfld, customerNameBldr)
      custNameSetIL.Emit(OpCodes.Ret)
      
      ' Last, we must map the two methods created above to our PropertyBuilder to 
      ' their corresponding behaviors, "get" and "set" respectively. 
      custNamePropBldr.SetGetMethod(custNameGetPropMthdBldr)
      custNamePropBldr.SetSetMethod(custNameSetPropMthdBldr)
            
      Dim retval As Type = myTypeBuilder.CreateType()

      ' Save the assembly so it can be examined with Ildasm.exe,
      ' or referenced by a test program.
      myAsmBuilder.Save(myAsmName.Name & ".dll")
      return retval
   End Function 'BuildDynamicTypeWithProperties
    
   
   Public Shared Sub Main()
      Dim custDataType As Type = BuildDynamicTypeWithProperties()
      
      Dim custDataPropInfo As PropertyInfo() = custDataType.GetProperties()
      Dim pInfo As PropertyInfo
      For Each pInfo In  custDataPropInfo
         Console.WriteLine("Property '{0}' created!", pInfo.ToString())
      Next pInfo
      
      Console.WriteLine("---")
      ' Note that when invoking a property, you need to use the proper BindingFlags -
      ' BindingFlags.SetProperty when you invoke the "set" behavior, and 
      ' BindingFlags.GetProperty when you invoke the "get" behavior. Also note that
      ' we invoke them based on the name we gave the property, as expected, and not
      ' the name of the methods we bound to the specific property behaviors.
      Dim custData As Object = Activator.CreateInstance(custDataType)
      custDataType.InvokeMember("CustomerName", BindingFlags.SetProperty, Nothing, _
                                custData, New Object() {"Joe User"})
      
      Console.WriteLine("The customerName field of instance custData has been set to '{0}'.", _
                        custDataType.InvokeMember("CustomerName", BindingFlags.GetProperty, _
                        Nothing, custData, New Object() {}))
   End Sub
End Class


' --- O U T P U T ---
' The output should be as follows:
' -------------------
' Property 'System.String CustomerName' created!
' ---
' The customerName field of instance custData has been set to 'Joe User'.
' -------------------

備註

PropertyBuilder 律與相關聯 TypeBuilderTypeBuilderDefineProperty 方法會將新的 PropertyBuilder 傳回給用戶端。

建構函式

PropertyBuilder()

初始化 PropertyBuilder 類別的新執行個體。

屬性

Attributes

取得這個屬性 (Property) 的屬性 (Attribute)。

CanRead

取得值,指出是否可讀取屬性。

CanWrite

取得值,指出是否可寫入屬性。

CustomAttributes

取得包含此成員之自訂屬性的集合。

(繼承來源 MemberInfo)
DeclaringType

取得宣告這個成員的類別。

GetMethod

取得這個屬性的 get 存取子。

(繼承來源 PropertyInfo)
IsCollectible

取得指出此 MemberInfo 物件是否為可回收 AssemblyLoadContext 中保存之組件一部分的值。

(繼承來源 MemberInfo)
IsSpecialName

取得值,指出屬性是否為特殊名稱。

(繼承來源 PropertyInfo)
MemberType

取得 MemberTypes 值,指出這個成員為屬性。

(繼承來源 PropertyInfo)
MetadataToken

取得值,這個值可識別中繼資料項目。

(繼承來源 MemberInfo)
Module

取得用於定義型別的模組,該型別宣告目前的屬性。

Module

取得用於定義型別的模組,該型別宣告以目前 MemberInfo 表示的成員。

(繼承來源 MemberInfo)
Name

取得這個成員的名稱。

PropertyToken

擷取這個屬性的語彙基元。

PropertyType

取得這個屬性的欄位型別。

ReflectedType

取得類別物件,是用來取得這個 MemberInfo 的執行個體。

ReflectedType

取得類別物件,是用來取得這個 MemberInfo 的執行個體。

(繼承來源 MemberInfo)
SetMethod

取得這個屬性的 set 存取子。

(繼承來源 PropertyInfo)

方法

AddOtherMethod(MethodBuilder)

加入其中一個與這個屬性相關聯的其他方法。

AddOtherMethodCore(MethodBuilder)

在衍生類別中覆寫時,新增與此屬性相關聯的其中一個其他方法。

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。

(繼承來源 PropertyInfo)
GetAccessors()

傳回陣列,其項目會反映目前執行個體所反映屬性之公用的 getset 存取子。

(繼承來源 PropertyInfo)
GetAccessors(Boolean)

傳回這個屬性上的公用 (Public) 和非公用 getset 存取子的陣列。

GetAccessors(Boolean)

傳回陣列,其項目會反映目前執行個體所反映的屬性公用的和 (如果指定) 非公用的 getset 存取子。

(繼承來源 PropertyInfo)
GetConstantValue()

使用編譯器傳回與屬性相關聯的常值。

(繼承來源 PropertyInfo)
GetCustomAttributes(Boolean)

傳回這個屬性 (Property) 的所有自訂屬性 (Attribute) 陣列。

GetCustomAttributes(Boolean)

在衍生類別中覆寫時,傳回套用至此成員之所有自訂屬性的陣列。

(繼承來源 MemberInfo)
GetCustomAttributes(Type, Boolean)

傳回由 Type 識別的自訂屬性陣列。

GetCustomAttributes(Type, Boolean)

當在衍生的類別中覆寫時,會傳回套用至這個成員的自訂屬性陣列,並以 Type 識別。

(繼承來源 MemberInfo)
GetCustomAttributesData()

傳回 CustomAttributeData 物件的清單,表示已套用至目標成員之屬性的資料。

(繼承來源 MemberInfo)
GetGetMethod()

傳回這個屬性的公用 get 存取子。

(繼承來源 PropertyInfo)
GetGetMethod(Boolean)

傳回這個屬性的公用和非公用 get 存取子。

GetGetMethod(Boolean)

當在衍生類別中覆寫時,傳回這個屬性的公用或非公用 get 存取子。

(繼承來源 PropertyInfo)
GetHashCode()

傳回這個執行個體的雜湊碼。

(繼承來源 PropertyInfo)
GetIndexParameters()

傳回屬性的所有索引參數陣列。

GetModifiedPropertyType()

取得這個屬性物件的修改類型。

(繼承來源 PropertyInfo)
GetOptionalCustomModifiers()

傳回類型的陣列,表示屬性的選擇性自訂修飾詞。

(繼承來源 PropertyInfo)
GetRawConstantValue()

使用編譯器傳回與屬性相關聯的常值。

(繼承來源 PropertyInfo)
GetRequiredCustomModifiers()

傳回類型的陣列,表示屬性的必要自訂修飾詞。

(繼承來源 PropertyInfo)
GetSetMethod()

傳回這個屬性的公用 set 存取子。

(繼承來源 PropertyInfo)
GetSetMethod(Boolean)

傳回這個屬性的 set 存取子。

GetSetMethod(Boolean)

當在衍生類別中覆寫時,傳回這個屬性的 set 存取子。

(繼承來源 PropertyInfo)
GetType()

探索屬性 (Property) 的屬性 (Attribute),並提供屬性中繼資料 (Metadata) 的存取。

(繼承來源 PropertyInfo)
GetValue(Object)

傳回指定的物件的屬性值。

(繼承來源 PropertyInfo)
GetValue(Object, BindingFlags, Binder, Object[], CultureInfo)

取得屬性值,其具有指定繫結、索引和 CultureInfo

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

當在衍生類別中覆寫時,傳回指定的物件的屬性值,此物件具有指定的繫結、索引和文化特性特定資訊。

(繼承來源 PropertyInfo)
GetValue(Object, Object[])

藉由呼叫屬性的 getter 方法,取得索引屬性的值。

HasSameMetadataDefinitionAs(MemberInfo)

定義型別的屬性。

(繼承來源 MemberInfo)
IsDefined(Type, Boolean)

指出 attributeType 的一或多個執行個體是否定義在這個屬性上。

IsDefined(Type, Boolean)

在衍生類別中覆寫時,表示是否已有一個或多個具有指定型別或其衍生型別的屬性套用至這個成員。

(繼承來源 MemberInfo)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
SetConstant(Object)

設定這個屬性的預設值。

SetConstantCore(Object)

在衍生類別中覆寫時,設定此屬性的預設值。

SetCustomAttribute(ConstructorInfo, Byte[])

使用指定的自訂屬性 Blob 來設定自訂屬性。

SetCustomAttribute(CustomAttributeBuilder)

使用自訂屬性產生器來設定自訂屬性。

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

在衍生類別中覆寫時,在此元件上設定自定義屬性。

SetGetMethod(MethodBuilder)

設定會取得屬性值的方法。

SetGetMethodCore(MethodBuilder)

在衍生類別中覆寫時,設定取得屬性值的方法。

SetSetMethod(MethodBuilder)

設定會設定屬性值的方法。

SetSetMethodCore(MethodBuilder)

在衍生類別中覆寫時,設定設定 屬性值的方法。

SetValue(Object, Object)

設定指定之物件的屬性值。

(繼承來源 PropertyInfo)
SetValue(Object, Object, BindingFlags, Binder, Object[], CultureInfo)

設定指定物件的屬性值為指定值。

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

當在衍生類別中覆寫時,設定指定的物件的屬性值,此物件具有指定的繫結、索引和文化特性特定資訊。

(繼承來源 PropertyInfo)
SetValue(Object, Object, Object[])

使用索引屬性的選擇性索引值設定屬性值。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

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

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 MemberInfo)
_MemberInfo.GetType()

取得 Type 物件,表示 MemberInfo 類別。

(繼承來源 MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 MemberInfo)
_PropertyBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

_PropertyBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

_PropertyBuilder.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

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

提供物件所公開的屬性和方法的存取權。

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

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 PropertyInfo)
_PropertyInfo.GetType()

取得 Type 物件,其代表 PropertyInfo 類型。

(繼承來源 PropertyInfo)
_PropertyInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 PropertyInfo)
_PropertyInfo.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 PropertyInfo)
_PropertyInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 PropertyInfo)
ICustomAttributeProvider.GetCustomAttributes(Boolean)

傳回這個成員中定義的所有自訂屬性的陣列 (但具名屬性除外),如果沒有自訂屬性,則傳回空陣列。

(繼承來源 MemberInfo)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

傳回這個成員中定義的自訂屬性陣列 (依類型識別),如果沒有該類型的自訂屬性,則傳回空陣列。

(繼承來源 MemberInfo)
ICustomAttributeProvider.IsDefined(Type, Boolean)

指出此成員上是否有定義一個或多個 attributeType 執行個體。

(繼承來源 MemberInfo)

擴充方法

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)

傳回值,指出所指定成員是否有可用的中繼資料語彙基元。

GetAccessors(PropertyInfo)

定義型別的屬性。

GetAccessors(PropertyInfo, Boolean)

定義型別的屬性。

GetGetMethod(PropertyInfo)

定義型別的屬性。

GetGetMethod(PropertyInfo, Boolean)

定義型別的屬性。

GetSetMethod(PropertyInfo)

定義型別的屬性。

GetSetMethod(PropertyInfo, Boolean)

定義型別的屬性。

適用於