TimeSpanValidatorAttribute Klasa

Definicja

Deklaratywnie instruuje platformę .NET, aby przeprowadzić walidację czasu we właściwości konfiguracji. Klasa ta nie może być dziedziczona.

public ref class TimeSpanValidatorAttribute sealed : System::Configuration::ConfigurationValidatorAttribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class TimeSpanValidatorAttribute : System.Configuration.ConfigurationValidatorAttribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type TimeSpanValidatorAttribute = class
    inherit ConfigurationValidatorAttribute
Public NotInheritable Class TimeSpanValidatorAttribute
Inherits ConfigurationValidatorAttribute
Dziedziczenie
TimeSpanValidatorAttribute
Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak ozdobić właściwości obiektu niestandardowego ConfigurationSection przy użyciu atrybutu TimeSpanValidatorAttribute .

[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;
    }
}
<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

Poniższy przykład to fragment pliku konfiguracji, który zawiera sekcję niestandardową używaną przez poprzedni przykład.

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

Uwagi

Atrybut służy TimeSpanValidatorAttribute do dekorowania właściwości konfiguracji. Jest to poinstruowanie platformy .NET o zweryfikowaniu właściwości przy użyciu TimeSpanValidator klasy i przekazaniu do niej wartości parametrów dekorowania.

Obiekty można stosować TimeSpanValidatorAttribute tylko do typów właściwości.

Konstruktory

TimeSpanValidatorAttribute()

Inicjuje nowe wystąpienie klasy TimeSpanValidatorAttribute.

Pola

TimeSpanMaxValue

Pobiera dozwoloną bezwzględną maksymalną wartość.

TimeSpanMinValue

Pobiera dozwoloną bezwzględną wartość minimalną.

Właściwości

ExcludeRange

Pobiera lub ustawia wartość wskazującą, czy należy uwzględnić lub wykluczyć liczby całkowite w zakresie zdefiniowanym przez MinValueString i MaxValueString.

MaxValue

Pobiera bezwzględną wartość maksymalną TimeSpan .

MaxValueString

Pobiera lub ustawia względną wartość maksymalną TimeSpan .

MinValue

Pobiera bezwzględną wartość minimalną TimeSpan .

MinValueString

Pobiera lub ustawia względną wartość minimalną TimeSpan .

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego elementu Attribute.

(Odziedziczone po Attribute)
ValidatorInstance

Pobiera wystąpienie TimeSpanValidator klasy.

ValidatorType

Pobiera typ atrybutu modułu sprawdzania poprawności.

(Odziedziczone po ConfigurationValidatorAttribute)

Metody

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

(Odziedziczone po Attribute)
GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

(Odziedziczone po Attribute)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
IsDefaultAttribute()

W przypadku zastąpienia w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

W przypadku zastąpienia w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie obiektu, którego można użyć do pobrania informacji o typie interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też