CustomAttributeBuilder 建構函式

定義

初始化該類別的 CustomAttributeBuilder 實例。

多載

名稱 Description
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 ,給定自訂屬性的建構子及建構子的參數。

public:
 CustomAttributeBuilder(System::Reflection::ConstructorInfo ^ con, cli::array <System::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 是靜態或私密。

-或-

所提供的參數數量與建構子呼叫慣例所要求的參數數不相符。

-或-

所提供的參數類型與建構子中宣告的參數類型不符。

-或-

所提供的參數是指除 String or Type以外的參考型別。

conconstructorArgsnull

備註

陣列的 constructorArgs 元素限制於元素類型。 它們可以是 bytesbyteuintcharintulongboollongfloatdoubleString一個列舉、一個型別、任何先前被鑄造到物件的前述型態,或是任何先前類型中的單維零基陣列。

適用於

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

初始化該類別的實例 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);
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[]

自訂屬性中命名欄位的值。

例外狀況

fieldValues 陣列的長度namedFields不同。

-或-

con 是靜態或私密。

-或-

所提供的參數數量與建構子呼叫慣例所要求的參數數不相符。

-或-

所提供的參數類型與建構子中宣告的參數類型不符。

-或-

欄位值的類型與命名欄位的類型不符。

-或-

該欄位不屬於與建構子相同的類別或基底類別。

-或-

所提供的參數或命名欄位是除 StringType之外的參考型別。

其中一個參數是 null

備註

fieldValues 陣列的constructorArgs元素限制於元素類型。 它們可以是 bytesbyteuintcharintulongboollongfloatdoubleString一個列舉、一個型別、任何先前被鑄造到物件的前述型態,或是任何先前類型中的單維零基陣列。

Important

請勿在 中包含私有欄位。namedFields 若如此 CustomAttributeFormatException ,當 GetCustomAttributes 該方法在完成型別上被呼叫時,會被拋出。

適用於

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

初始化該類別的實例 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);
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[]

自訂屬性的命名屬性。

propertyValues
Object[]

自訂屬性中命名屬性的值。

例外狀況

propertyValues 陣列的長度namedProperties不同。

-或-

con 是靜態或私密。

-或-

所提供的參數數量與建構子呼叫慣例所要求的參數數不相符。

-或-

所提供的參數類型與建構子中宣告的參數類型不符。

-或-

房產價值的類型與所命名房產的類型不符。

-或-

屬性沒有設定方法。

-或-

該屬性不屬於與建構子相同的類別或基底類別。

-或-

所提供的參數或命名屬性是指除 StringType之外的參考型別。

其中一個參數是 null

備註

propertyValues 陣列的constructorArgs元素限制於元素類型。 它們可以是 bytesbyteuintcharintulongboollongfloatdoubleString一個列舉、一個型別、任何先前被鑄造到物件的前述型態,或是任何先前類型中的單維零基陣列。

Important

請勿將私人財產納入 namedProperties。 若如此 CustomAttributeFormatException ,當 GetCustomAttributes 該方法在完成型別上被呼叫時,會被拋出。

適用於

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

初始化該類別的實例 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);
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[]

自訂屬性的命名屬性。

propertyValues
Object[]

自訂屬性中命名屬性的值。

namedFields
FieldInfo[]

自訂屬性的命名欄位。

fieldValues
Object[]

自訂屬性中命名欄位的值。

例外狀況

propertyValues 陣列的長度namedProperties不同。

-或-

fieldValues 陣列的長度namedFields不同。

-或-

con 是靜態或私密。

-或-

所提供的參數數量與建構子呼叫慣例所要求的參數數不相符。

-或-

所提供的參數類型與建構子中宣告的參數類型不符。

-或-

房產價值的類型與所命名房產的類型不符。

-或-

欄位值的類型與對應欄位類型的類型不相符。

-或-

一個屬性沒有設定者。

-或-

屬性或欄位不屬於與建構子相同的類別或基底類別。

-或-

所提供的參數、命名屬性或命名欄位是除 StringType之外的參考型別。

其中一個參數是 null

備註

、 或 fieldValues 陣列的constructorArgspropertyValues元素限制於元素類型。 它們可以是 bytesbyteuintcharintulongboollongfloatdoubleString一個列舉、一個型別、任何先前被鑄造到物件的前述型態,或是任何先前類型中的單維零基陣列。

Important

請勿將私人財產或田地納入 namedPropertiesnamedFields。 若如此 CustomAttributeFormatException ,當 GetCustomAttributes 該方法在完成型別上被呼叫時,會被拋出。

適用於