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 类的实例。

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 元素仅限于元素类型。 它们可以是byte、、、、uint``ulong``double``bool``int``char``long``String``float枚举、类型、已转换为对象的任何先前类型,或从零开始的任意上一种类型的数组。 sbyte

适用于

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);
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仅限于元素类型。 它们可以是byte、、、、uint``ulong``double``bool``int``char``long``String``float枚举、类型、已转换为对象的任何先前类型,或从零开始的任意上一种类型的数组。 sbyte

重要

请勿在 . 中 namedFields包括专用字段。 在完成类型上调用该方法时GetCustomAttributes,这样做将导致CustomAttributeFormatException引发。

适用于

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);
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仅限于元素类型。 它们可以是byte、、、、uint``ulong``double``bool``int``char``long``String``float枚举、类型、已转换为对象的任何先前类型,或从零开始的任意上一种类型的数组。 sbyte

重要

请勿在 . 中 namedProperties包括专用属性。 在完成类型上调用该方法时GetCustomAttributes,这样做将导致CustomAttributeFormatException引发。

适用于

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);
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

注解

或数组的constructorArgs``propertyValues``fieldValues元素仅限于元素类型。 它们可以是byte、、、、uint``ulong``double``bool``int``char``long``String``float枚举、类型、已转换为对象的任何先前类型,或从零开始的任意上一种类型的数组。 sbyte

重要

请勿在或namedFields中包括私有属性或字段namedProperties。 在完成类型上调用该方法时GetCustomAttributes,这样做将导致CustomAttributeFormatException引发。

适用于