TimeSpanValidatorAttribute Classe
Definição
Instrui de modo declarativo o .NET a executar a validação de tempo em uma propriedade de configuração.Declaratively instructs .NET to perform time validation on a configuration property. Essa classe não pode ser herdada.This class cannot be inherited.
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
- Herança
- Atributos
Exemplos
O exemplo a seguir mostra como decorar as propriedades de um ConfigurationSection objeto personalizado usando o TimeSpanValidatorAttribute atributo.The following example shows how to decorate the properties of a custom ConfigurationSection object using the TimeSpanValidatorAttribute attribute.
[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
O exemplo a seguir é um trecho do arquivo de configuração que contém a seção personalizada usada pelo exemplo anterior.The following example is an excerpt of the configuration file that contains the custom section used by the previous sample.
<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>
Comentários
Você usa o TimeSpanValidatorAttribute atributo para decorar uma propriedade de configuração.You use the TimeSpanValidatorAttribute attribute to decorate a configuration property. Isso é para instruir o .NET a validar a propriedade usando a TimeSpanValidator classe e passar para ela o valor dos parâmetros de decoração.This is to instruct .NET to validate the property using the TimeSpanValidator class and pass to it the value of the decorating parameters.
Você pode aplicar TimeSpanValidatorAttribute objetos somente a tipos de propriedade.You can apply TimeSpanValidatorAttribute objects to property types only.
Construtores
| TimeSpanValidatorAttribute() |
Inicializa uma nova instância da classe TimeSpanValidatorAttribute.Initializes a new instance of the TimeSpanValidatorAttribute class. |
Campos
| TimeSpanMaxValue |
Obtém o valor absoluto máximo permitido.Gets the absolute maximum value allowed. |
| TimeSpanMinValue |
Obtém o valor absoluto mínimo permitido.Gets the absolute minimum value allowed. |
Propriedades
| ExcludeRange |
Obtém ou define um valor que indica se é necessário incluir ou excluir os inteiros no intervalo, conforme definido por MinValueString e MaxValueString.Gets or sets a value that indicates whether to include or exclude the integers in the range as defined by MinValueString and MaxValueString. |
| MaxValue |
Obtém o valor absoluto TimeSpan máximo.Gets the absolute maximum TimeSpan value. |
| MaxValueString |
Obtém ou define o valor máximo relativo TimeSpan.Gets or sets the relative maximum TimeSpan value. |
| MinValue |
Obtém o valor absoluto TimeSpan mínimo.Gets the absolute minimum TimeSpan value. |
| MinValueString |
Obtém ou define o valor mínimo relativo TimeSpan.Gets or sets the relative minimum TimeSpan value. |
| TypeId |
Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute. (Herdado de Attribute) |
| ValidatorInstance |
Obtém uma instância da classe TimeSpanValidator.Gets an instance of the TimeSpanValidator class. |
| ValidatorType |
Obtém o tipo do atributo do validador.Gets the type of the validator attribute. (Herdado de ConfigurationValidatorAttribute) |
Métodos
| Equals(Object) |
Retorna um valor que indica se essa instância é igual a um objeto especificado.Returns a value that indicates whether this instance is equal to a specified object. (Herdado de Attribute) |
| GetHashCode() |
Retorna o código hash para a instância.Returns the hash code for this instance. (Herdado de Attribute) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| IsDefaultAttribute() |
Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Herdado de Attribute) |
| Match(Object) |
Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Herdado de Attribute) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |
Implantações explícitas de interface
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.Maps a set of names to a corresponding set of dispatch identifiers. (Herdado de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.Retrieves the type information for an object, which can be used to get the type information for an interface. (Herdado de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Herdado de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fornece acesso a propriedades e métodos expostos por um objeto.Provides access to properties and methods exposed by an object. (Herdado de Attribute) |