ConfigurationPropertyAttribute クラス
アセンブリ: System.Configuration (system.configuration.dll 内)

<AttributeUsageAttribute(AttributeTargets.Property)> _ Public NotInheritable Class ConfigurationPropertyAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Property)] public sealed class ConfigurationPropertyAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] public ref class ConfigurationPropertyAttribute sealed : public Attribute

ConfigurationPropertyAttribute を使用して、.NET Framework にインスタンス化を指示する構成プロパティを装飾し、装飾のパラメータの値を使用してプロパティを初期化します。
![]() |
---|
カスタムの構成要素を作成する最も簡単な方法は、属性付き (宣言) モデルを使用することです。カスタムのパブリック プロパティを宣言し、それらを ConfigurationPropertyAttribute 属性で装飾します。.NET Framework は、この属性でマークされたプロパティごとに、リフレクションを使用して装飾のパラメータを読み取り、関連する ConfigurationProperty インスタンスを作成します。また、プログラム モデルも使用できます。この場合には、開発者が、カスタムのパブリック プロパティを宣言し、それらのコレクションを返す必要があります。 |
.NET Framework 構成システムには、カスタムの構成要素の作成時に使用できる属性の型が用意されています。2 種類の属性の型があります。
-
.NET Framework に、カスタムの構成要素のプロパティをインスタンス化する方法を指示する型。次の属性がこれらの型に含まれます。
-
ConfigurationCollectionAttribute
-
ConfigurationPropertyAttribute
-
-
.NET Framework に、カスタムの構成要素のプロパティを検証する方法を指示する型。次の属性がこれらの型に含まれます。
-
IntegerValidatorAttribute
-
LongValidatorAttribute
-
RegexStringValidatorAttribute
-
StringValidatorAttribute
-
TimeSpanValidatorAttribute
-

ConfigurationPropertyAttribute 属性を使用して、カスタム ConfigurationSection オブジェクトのプロパティを装飾する方法を、次のコード例に示します。
Public Class SampleSection Inherits ConfigurationSection Public Sub New() End Sub 'New <ConfigurationProperty("fileName", _ DefaultValue:="default.txt", _ IsRequired:=True, _ IsKey:=False), _ StringValidator( _ InvalidCharacters:=" ~!@#$%^&*()[]{}/;'""|\", _ MinLength:=1, _ MaxLength:=60)> _ Public Property FileName() As String Get Return CStr(Me("fileName")) End Get Set(ByVal value As String) Me("fileName") = value End Set End Property <ConfigurationProperty("maxUsers", _ DefaultValue:=10000, _ IsRequired:=False), _ LongValidator(MinValue:=1, _ MaxValue:=10000000, _ ExcludeRange:=False)> _ Public Property MaxUsers() As Long Get Return Fix(Me("maxUsers")) End Get Set(ByVal value As Long) Me("maxUsers") = value End Set End Property <ConfigurationProperty("maxIdleTime", _ DefaultValue:="0:10:0", _ IsRequired:=False), _ TimeSpanValidator(MinValueString:="0:0:30", _ MaxValueString:="5:00:0", _ ExcludeRange:=False)> _ Public Property MaxIdleTime() As TimeSpan Get Return CType(Me("maxIdleTime"), TimeSpan) End Get Set(ByVal value As TimeSpan) Me("maxIdleTime") = value End Set End Property
public class SampleSection : ConfigurationSection { public SampleSection() { } [ConfigurationProperty("fileName", DefaultValue = "default.txt" , IsRequired = true, IsKey = false)] [StringValidator(InvalidCharacters = " ~!@#$%^&*()[]{}/;'\"|\\" , MinLength = 1, MaxLength = 60)] public string FileName { get { return (string)this["fileName"]; } set { this["fileName"] = value; } } [ConfigurationProperty("maxUsers", DefaultValue = (long)10000, IsRequired=false)] [LongValidator(MinValue = 1, MaxValue = 10000000, ExcludeRange = false)] public long MaxUsers { get { return (long)this["maxUsers"]; } set { this["maxUsers"] = value; } } [ConfigurationProperty("maxIdleTime", DefaultValue = "0:10:0", IsRequired = false)] [TimeSpanValidator(MinValueString = "0:0:30", MaxValueString = "5:00:0", ExcludeRange = false)] public TimeSpan MaxIdleTime { get { return (TimeSpan)this["maxIdleTime"]; } set { this["maxIdleTime"] = value; } } }

System.Attribute
System.Configuration.ConfigurationPropertyAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ConfigurationPropertyAttribute コンストラクタ
アセンブリ: System.Configuration (system.configuration.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ConfigurationPropertyAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | DefaultValue | 装飾されたプロパティの既定値を取得または設定します。 |
![]() | IsDefaultCollection | これが、装飾された構成プロパティに対する既定プロパティのコレクションかどうかを示す値を取得または設定します。 |
![]() | IsKey | これが、装飾された要素のプロパティに対する主要プロパティかどうかを示す値を取得または設定します。 |
![]() | IsRequired | 装飾された要素のプロパティが必要かどうかを示す値を取得または設定します。 |
![]() | Name | 装飾された構成要素のプロパティの名前を取得または設定します。 |
![]() | Options | 装飾された構成要素のプロパティの ConfigurationPropertyOptions を取得または設定します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

関連項目
ConfigurationPropertyAttribute クラスSystem.Configuration 名前空間
ConfigurationProperty クラス
ConfigurationCollectionAttribute クラス
IntegerValidatorAttribute
LongValidatorAttribute
RegexStringValidatorAttribute
StringValidatorAttribute
TimeSpanValidatorAttribute
ConfigurationPropertyAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

関連項目
ConfigurationPropertyAttribute クラスSystem.Configuration 名前空間
ConfigurationProperty クラス
ConfigurationCollectionAttribute クラス
IntegerValidatorAttribute
LongValidatorAttribute
RegexStringValidatorAttribute
StringValidatorAttribute
TimeSpanValidatorAttribute
ConfigurationPropertyAttribute メンバ
.NET Framework が構成プロパティをインスタンス化するように、宣言によって指示します。このクラスは継承できません。
ConfigurationPropertyAttribute データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | DefaultValue | 装飾されたプロパティの既定値を取得または設定します。 |
![]() | IsDefaultCollection | これが、装飾された構成プロパティに対する既定プロパティのコレクションかどうかを示す値を取得または設定します。 |
![]() | IsKey | これが、装飾された要素のプロパティに対する主要プロパティかどうかを示す値を取得または設定します。 |
![]() | IsRequired | 装飾された要素のプロパティが必要かどうかを示す値を取得または設定します。 |
![]() | Name | 装飾された構成要素のプロパティの名前を取得または設定します。 |
![]() | Options | 装飾された構成要素のプロパティの ConfigurationPropertyOptions を取得または設定します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

関連項目
ConfigurationPropertyAttribute クラスSystem.Configuration 名前空間
ConfigurationProperty クラス
ConfigurationCollectionAttribute クラス
IntegerValidatorAttribute
LongValidatorAttribute
RegexStringValidatorAttribute
StringValidatorAttribute
TimeSpanValidatorAttribute
- ConfigurationPropertyAttributeのページへのリンク