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)

來源:
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 類別的新執行個體。

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

來源:
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 類別的新執行個體。

此 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 類別的新執行個體。

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

另請參閱

適用於