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

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

TimeSpanValidatorAttribute を使用して、構成プロパティを装飾します。これは、.NET Framework に TimeSpanValidator を使用してプロパティを検証するように指示し、装飾のパラメータの値を渡すためです。

TimeSpanValidatorAttribute オブジェクトを使用して、カスタム ConfigurationSection オブジェクトのプロパティを装飾する方法を、次のコード例に示します。
<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
[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; } }
次に示すのは、前述の例で使用されているカスタム セクションを含んだ構成ファイルの抜粋です。
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <configSections> <section name="custom" type="Microsoft.Samples.AspNet.Configuration.SampleSection, ConfigurationValidatorAttribute" /> </configSections> <custom fileName="NewFile.txt" maxSize="1000" maxAttempts="101" maxUsers="2500" maxIdleTime="00:15:00" /> </configuration>

System.Attribute
System.Configuration.ConfigurationValidatorAttribute
System.Configuration.TimeSpanValidatorAttribute


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- TimeSpanValidatorAttribute クラスのページへのリンク