語言

ConfigurationProperty 建構函式

定義

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

多載

名稱 Description
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)

來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
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)

來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
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) 建構子實例化配置屬性物件。

// 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 時, IsRequired 和 IsKey 屬性會被設定為 false。 此外,使用此建構子建立的實例不會作為預設的集合金鑰屬性。

另請參閱

適用於

ConfigurationProperty(String, Type, Object, ConfigurationPropertyOptions)

來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
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)

來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
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)

來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
ConfigurationProperty.cs
來源:
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) 建構子實例化配置屬性物件。

// 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.]")

另請參閱

適用於