CustomAttributeBuilder 建構函式

定義

初始化 CustomAttributeBuilder 類別的執行個體。

多載

CustomAttributeBuilder(ConstructorInfo, Object[])

指定自訂屬性的建構函式與建構函式的引數,初始化 CustomAttributeBuilder 類別的執行個體。

CustomAttributeBuilder(ConstructorInfo, Object[], FieldInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的欄位/值配對。

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的屬性或值配對。

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[])

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數、一組命名的屬性或值配對,以及一組命名的欄位或值配對。

CustomAttributeBuilder(ConstructorInfo, Object[])

來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs

指定自訂屬性的建構函式與建構函式的引數,初始化 CustomAttributeBuilder 類別的執行個體。

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。

constructorArgs
Object[]

自訂屬性之建構函式的引數。

例外狀況

con 為靜態或私用的。

-或-

提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。

-或-

提供的引數類型不符合建構函式中宣告的參數類型。

-或-

提供的引數不是 StringType 的參考類型。

conconstructorArgsnull

備註

陣列的專案 constructorArgs 僅限於項目類型。 它們可以是 、、、intcharlongStringfloatulongbooluintdouble列舉、類型、任何轉換成物件的先前類型,或是任何先前類型之以零為基底的單一維度陣列。 sbytebyte

適用於

CustomAttributeBuilder(ConstructorInfo, Object[], FieldInfo[], Object[])

來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的欄位/值配對。

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs, cli::array <System::Reflection::FieldInfo ^> ^ namedFields, cli::array <System::Object ^> ^ fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] * System.Reflection.FieldInfo[] * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object(), namedFields As FieldInfo(), fieldValues As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。

constructorArgs
Object[]

自訂屬性之建構函式的引數。

namedFields
FieldInfo[]

自訂屬性的具名欄位。

fieldValues
Object[]

自訂屬性的具名欄位值。

例外狀況

namedFieldsfieldValues 陣列的長度不同。

-或-

con 為靜態或私用的。

-或-

提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。

-或-

提供的引數類型不符合建構函式中宣告的參數類型。

-或-

欄位值型別不符合具名欄位型別。

-或-

欄位不屬於做為建構函式的相同類別或基底類別。

-或-

提供的引數或具名欄位是 StringType 以外的參考型別。

其中一個參數為 null

備註

fieldValues 陣列的專案constructorArgs僅限於項目類型。 它們可以是 、、、intcharlongStringfloatulongbooluintdouble列舉、類型、任何轉換成物件的先前類型,或是任何先前類型之以零為基底的單一維度陣列。 sbytebyte

重要

請勿在 中包含 namedFields私用欄位。 這麼做會導致 CustomAttributeFormatException 在稍後在完成的類型上呼叫 方法時 GetCustomAttributes 擲回。

適用於

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[])

來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數,以及一組命名的屬性或值配對。

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs, cli::array <System::Reflection::PropertyInfo ^> ^ namedProperties, cli::array <System::Object ^> ^ propertyValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] * System.Reflection.PropertyInfo[] * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object(), namedProperties As PropertyInfo(), propertyValues As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。

constructorArgs
Object[]

自訂屬性之建構函式的引數。

namedProperties
PropertyInfo[]

自訂屬性 (Attribute) 的具名屬性 (Property)。

propertyValues
Object[]

自訂屬性 (Attribute) 的具名屬性 (Property) 值。

例外狀況

namedPropertiespropertyValues 陣列的長度不同。

-或-

con 為靜態或私用的。

-或-

提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。

-或-

提供的引數類型不符合建構函式中宣告的參數類型。

-或-

屬性值型別不符合具名屬性型別。

-或-

屬性不具有 Setter 方法。

-或-

屬性不屬於做為建構函式的相同類別或基底類別。

-或-

提供的引數或具名屬性是 StringType 以外的參考型別。

其中一個參數為 null

備註

propertyValues 陣列的專案constructorArgs僅限於項目類型。 它們可以是 、、、intcharlongStringfloatulongbooluintdouble列舉、類型、任何轉換成物件的先前類型,或是任何先前類型之以零為基底的單一維度陣列。 sbytebyte

重要

請勿在 中包含 namedProperties私用屬性。 這麼做會導致 CustomAttributeFormatException 在稍後在完成的類型上呼叫 方法時 GetCustomAttributes 擲回。

適用於

CustomAttributeBuilder(ConstructorInfo, Object[], PropertyInfo[], Object[], FieldInfo[], Object[])

來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs
來源:
CustomAttributeBuilder.cs

初始化 CustomAttributeBuilder 類別的執行個體,該類別指定了自訂屬性的建構函式、建構函式的引數、一組命名的屬性或值配對,以及一組命名的欄位或值配對。

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::Object ^> ^ constructorArgs, cli::array <System::Reflection::PropertyInfo ^> ^ namedProperties, cli::array <System::Object ^> ^ propertyValues, cli::array <System::Reflection::FieldInfo ^> ^ namedFields, cli::array <System::Object ^> ^ fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
public CustomAttributeBuilder (System.Reflection.ConstructorInfo con, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues);
new System.Reflection.Emit.CustomAttributeBuilder : System.Reflection.ConstructorInfo * obj[] * System.Reflection.PropertyInfo[] * obj[] * System.Reflection.FieldInfo[] * obj[] -> System.Reflection.Emit.CustomAttributeBuilder
Public Sub New (con As ConstructorInfo, constructorArgs As Object(), namedProperties As PropertyInfo(), propertyValues As Object(), namedFields As FieldInfo(), fieldValues As Object())

參數

con
ConstructorInfo

自訂屬性的建構函式。

constructorArgs
Object[]

自訂屬性之建構函式的引數。

namedProperties
PropertyInfo[]

自訂屬性 (Attribute) 的具名屬性 (Property)。

propertyValues
Object[]

自訂屬性 (Attribute) 的具名屬性 (Property) 值。

namedFields
FieldInfo[]

自訂屬性的具名欄位。

fieldValues
Object[]

自訂屬性的具名欄位值。

例外狀況

namedPropertiespropertyValues 陣列的長度不同。

-或-

namedFieldsfieldValues 陣列的長度不同。

-或-

con 為靜態或私用的。

-或-

提供的引數數目不符合建構函式呼叫慣例所需之建構函式的參數數目。

-或-

提供的引數類型不符合建構函式中宣告的參數類型。

-或-

屬性值型別不符合具名屬性型別。

-或-

欄位值型別不符合對應欄位型別的型別。

-或-

屬性不具有 Setter。

-或-

屬性或欄位不屬於做為建構函式的相同類別或基底類別。

-或-

提供的引數、具名屬性或具名欄位是 StringType 以外的參考型別。

其中一個參數為 null

備註

propertyValuesfieldValues 陣列的專案constructorArgs受限於項目類型。 它們可以是 、、、intcharlongStringfloatulongbooluintdouble列舉、類型、任何先前轉換成物件的類型,或是任何先前類型之以零起始的單一維度陣列。 sbytebyte

重要

請勿在 或 namedFields中包含namedProperties私人屬性或欄位。 這麼做會導致 CustomAttributeFormatException 在稍後在完成類型上呼叫 方法時 GetCustomAttributes 擲回。

適用於