Share via


ConfigurationProperty 构造函数

定义

初始化 ConfigurationProperty 类的新实例。

重载

ConfigurationProperty(String, Type)

此 API 支持产品基础结构,不能在代码中直接使用。

初始化 ConfigurationProperty 类的新实例。

ConfigurationProperty(String, Type, Object)

此 API 支持产品基础结构,不能在代码中直接使用。

初始化 ConfigurationProperty 类的新实例。

ConfigurationProperty(String, Type, Object, ConfigurationPropertyOptions)

此 API 支持产品基础结构,不能在代码中直接使用。

初始化 ConfigurationProperty 类的新实例。

ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions)

此 API 支持产品基础结构,不能在代码中直接使用。

初始化 ConfigurationProperty 类的新实例。

ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions, String)

此 API 支持产品基础结构,不能在代码中直接使用。

初始化 ConfigurationProperty 类的新实例。

ConfigurationProperty(String, Type)

Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs

初始化 ConfigurationProperty 类的新实例。

此 API 支持产品基础结构,不能在代码中直接使用。

public:
 ConfigurationProperty(System::String ^ name, Type ^ type);
public ConfigurationProperty (string name, Type type);
new System.Configuration.ConfigurationProperty : string * Type -> System.Configuration.ConfigurationProperty
Public Sub New (name As String, type As Type)

参数

name
String

配置实体的名称。

type
Type

配置实体的类型。

适用于

ConfigurationProperty(String, Type, Object)

Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs

初始化 ConfigurationProperty 类的新实例。

此 API 支持产品基础结构,不能在代码中直接使用。

public:
 ConfigurationProperty(System::String ^ name, Type ^ type, System::Object ^ defaultValue);
public ConfigurationProperty (string name, Type type, object defaultValue);
new System.Configuration.ConfigurationProperty : string * Type * obj -> System.Configuration.ConfigurationProperty
Public Sub New (name As String, type As Type, defaultValue As Object)

参数

name
String

配置实体的名称。

type
Type

配置实体的类型。

defaultValue
Object

配置实体的默认值。

示例

下面的代码示例演示如何使用 ConfigurationProperty.ConfigurationProperty(String, Type, Object) 构造函数实例化 configuration-property 对象。

// Initialize the _FileName property
_FileName =
    new ConfigurationProperty("fileName",
    typeof(string), "default.txt");
' Initialize the _FileName property
_FileName = New ConfigurationProperty( _
    "fileName", GetType(String), "default.txt")

注解

使用此构造函数实例化 ConfigurationProperty 对象时, IsRequiredIsKey 属性设置为 false。 此外,使用此构造函数创建的实例不会用作默认集合键属性。

另请参阅

适用于

ConfigurationProperty(String, Type, Object, ConfigurationPropertyOptions)

Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs

初始化 ConfigurationProperty 类的新实例。

此 API 支持产品基础结构,不能在代码中直接使用。

public:
 ConfigurationProperty(System::String ^ name, Type ^ type, System::Object ^ defaultValue, System::Configuration::ConfigurationPropertyOptions options);
public ConfigurationProperty (string name, Type type, object defaultValue, System.Configuration.ConfigurationPropertyOptions options);
new System.Configuration.ConfigurationProperty : string * Type * obj * System.Configuration.ConfigurationPropertyOptions -> System.Configuration.ConfigurationProperty
Public Sub New (name As String, type As Type, defaultValue As Object, options As ConfigurationPropertyOptions)

参数

name
String

配置实体的名称。

type
Type

配置实体的类型。

defaultValue
Object

配置实体的默认值。

示例

下面的代码示例演示如何使用 ConfigurationProperty.ConfigurationProperty(String, Type, Object, ConfigurationPropertyOptions) 构造函数实例化配置属性对象。

// Initialize the _MaxUsers property
_MaxUsers =
    new ConfigurationProperty("maxUsers",
    typeof(long), (long)1000,
    ConfigurationPropertyOptions.None);
' Initialize the _MaxUsers property
_MaxUsers = New ConfigurationProperty( _
    "maxUsers", GetType(Long), 1000L, _
    ConfigurationPropertyOptions.None)

另请参阅

适用于

ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions)

Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs

初始化 ConfigurationProperty 类的新实例。

此 API 支持产品基础结构,不能在代码中直接使用。

public:
 ConfigurationProperty(System::String ^ name, Type ^ type, System::Object ^ defaultValue, System::ComponentModel::TypeConverter ^ typeConverter, System::Configuration::ConfigurationValidatorBase ^ validator, System::Configuration::ConfigurationPropertyOptions options);
public ConfigurationProperty (string name, Type type, object defaultValue, System.ComponentModel.TypeConverter typeConverter, System.Configuration.ConfigurationValidatorBase validator, System.Configuration.ConfigurationPropertyOptions options);
new System.Configuration.ConfigurationProperty : string * Type * obj * System.ComponentModel.TypeConverter * System.Configuration.ConfigurationValidatorBase * System.Configuration.ConfigurationPropertyOptions -> System.Configuration.ConfigurationProperty
Public Sub New (name As String, type As Type, defaultValue As Object, typeConverter As TypeConverter, validator As ConfigurationValidatorBase, options As ConfigurationPropertyOptions)

参数

name
String

配置实体的名称。

type
Type

配置实体的类型。

defaultValue
Object

配置实体的默认值。

typeConverter
TypeConverter

要应用的转换器类型。

validator
ConfigurationValidatorBase

要使用的验证程序。

示例

下面的代码示例演示调用 ConfigurationProperty.ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions) 构造函数时要使用的参数类型。

// Initialize the _MaxIdleTime property
TimeSpan minTime = TimeSpan.FromSeconds(30);
TimeSpan maxTime = TimeSpan.FromMinutes(5);

ConfigurationValidatorBase _TimeSpanValidator =
    new TimeSpanValidator(minTime, maxTime, false);

_MaxIdleTime =
    new ConfigurationProperty("maxIdleTime",
    typeof(TimeSpan), TimeSpan.FromMinutes(5),
    TypeDescriptor.GetConverter(typeof(TimeSpan)),
    _TimeSpanValidator,
    ConfigurationPropertyOptions.IsRequired,
    "[Description:This is the max idle time.]");
' Initialize the _MaxIdleTime property
Dim minTime As TimeSpan = TimeSpan.FromSeconds(30)
Dim maxTime As TimeSpan = TimeSpan.FromMinutes(5)
Dim _TimeSpanValidator = _
    New TimeSpanValidator(minTime, maxTime, False)

_MaxIdleTime = New ConfigurationProperty( _
    "maxIdleTime", GetType(TimeSpan), _
    TimeSpan.FromMinutes(5), _
    TypeDescriptor.GetConverter(GetType(TimeSpan)), _
    _TimeSpanValidator, _
    ConfigurationPropertyOptions.IsRequired, _
    "[Description:This is the max idle time.]")

另请参阅

适用于

ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions, String)

Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs
Source:
ConfigurationProperty.cs

初始化 ConfigurationProperty 类的新实例。

此 API 支持产品基础结构,不能在代码中直接使用。

public:
 ConfigurationProperty(System::String ^ name, Type ^ type, System::Object ^ defaultValue, System::ComponentModel::TypeConverter ^ typeConverter, System::Configuration::ConfigurationValidatorBase ^ validator, System::Configuration::ConfigurationPropertyOptions options, System::String ^ description);
public ConfigurationProperty (string name, Type type, object defaultValue, System.ComponentModel.TypeConverter typeConverter, System.Configuration.ConfigurationValidatorBase validator, System.Configuration.ConfigurationPropertyOptions options, string description);
new System.Configuration.ConfigurationProperty : string * Type * obj * System.ComponentModel.TypeConverter * System.Configuration.ConfigurationValidatorBase * System.Configuration.ConfigurationPropertyOptions * string -> System.Configuration.ConfigurationProperty
Public Sub New (name As String, type As Type, defaultValue As Object, typeConverter As TypeConverter, validator As ConfigurationValidatorBase, options As ConfigurationPropertyOptions, description As String)

参数

name
String

配置实体的名称。

type
Type

配置实体的类型。

defaultValue
Object

配置实体的默认值。

typeConverter
TypeConverter

要应用的转换器类型。

validator
ConfigurationValidatorBase

要使用的验证程序。

description
String

配置实体的说明。

示例

下面的代码示例演示如何使用 ConfigurationProperty.ConfigurationProperty(String, Type, Object, TypeConverter, ConfigurationValidatorBase, ConfigurationPropertyOptions, String) 构造函数实例化 configuration-property 对象。

// Initialize the _MaxIdleTime property
TimeSpan minTime = TimeSpan.FromSeconds(30);
TimeSpan maxTime = TimeSpan.FromMinutes(5);

ConfigurationValidatorBase _TimeSpanValidator =
    new TimeSpanValidator(minTime, maxTime, false);

_MaxIdleTime =
    new ConfigurationProperty("maxIdleTime",
    typeof(TimeSpan), TimeSpan.FromMinutes(5),
    TypeDescriptor.GetConverter(typeof(TimeSpan)),
    _TimeSpanValidator,
    ConfigurationPropertyOptions.IsRequired,
    "[Description:This is the max idle time.]");
' Initialize the _MaxIdleTime property
Dim minTime As TimeSpan = TimeSpan.FromSeconds(30)
Dim maxTime As TimeSpan = TimeSpan.FromMinutes(5)
Dim _TimeSpanValidator = _
    New TimeSpanValidator(minTime, maxTime, False)

_MaxIdleTime = New ConfigurationProperty( _
    "maxIdleTime", GetType(TimeSpan), _
    TimeSpan.FromMinutes(5), _
    TypeDescriptor.GetConverter(GetType(TimeSpan)), _
    _TimeSpanValidator, _
    ConfigurationPropertyOptions.IsRequired, _
    "[Description:This is the max idle time.]")

另请参阅

适用于