StringValidatorAttribute Construtor

Definição

Inicializa uma nova instância da classe StringValidatorAttribute.Initializes a new instance of the StringValidatorAttribute class.

public:
 StringValidatorAttribute();
public StringValidatorAttribute ();
Public Sub New ()

Exemplos

O exemplo a seguir mostra como usar o StringValidatorAttribute Construtor.The following example shows how to use the StringValidatorAttribute constructor.

[ConfigurationProperty("alias", DefaultValue = "anotherName.txt",
    IsRequired = true, IsKey = false)]
[StringValidator()]
public string Alias
{
    get
    {
        return (string)this["alias"];
    }
    set
    {
        this["alias"] = value;
    }
}
<ConfigurationProperty("alias", _
DefaultValue:="anotherName.txt", _
IsRequired:=True, _
IsKey:=False), _
StringValidator()> _
Public Property [Alias]() As String
    Get
        Return CStr(Me("alias"))
    End Get
    Set(ByVal value As String)
        Me("alias") = value
    End Set
End Property

Comentários

Você usa esse construtor no modelo atribuído para garantir que o valor atribuído à propriedade do elemento Configuration seja de um tipo de cadeia de caracteres.You use this constructor in the attributed model to ensure that the value assigned to the configuration-element property is of a string type.

Aplica-se a

Confira também