Rediger

RegexStringValidatorAttribute Class

Definition

Declaratively instructs .NET to perform string validation on a configuration property using a regular expression. This class cannot be inherited.

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

Examples

The following example shows how to decorate the properties of a custom ConfigurationSection object using the RegexStringValidatorAttribute object.

[ConfigurationProperty("alias2", DefaultValue = "alias.txt",
    IsRequired = true, IsKey = false)]
[RegexStringValidator(@"\w+\S*")]
public string Alias2
{
    get
    {
        return (string)this["alias2"];
    }
    set
    {
        this["alias2"] = value;
    }
}
<ConfigurationProperty("alias2", _
DefaultValue:="alias.txt", _
IsRequired:=True, _
IsKey:=False), _
RegexStringValidator("\w+\S*")> _
Public Property Alias2() As String
    Get
        Return CStr(Me("alias2"))
    End Get
    Set(ByVal value As String)
        Me("alias2") = value
    End Set
End Property

Remarks

You use the RegexStringValidatorAttribute to decorate a configuration property, which instructs .NET to validate the property using RegexStringValidator and pass to it the value of the decorating parameters.

You can only apply RegexStringValidatorAttribute objects to property types.

Constructors

Name Description
RegexStringValidatorAttribute(String)

Initializes a new instance of the RegexStringValidatorAttribute object.

Properties

Name Description
Regex

Gets the string used to perform regular-expression validation.

ValidatorInstance

Gets an instance of the RegexStringValidator class.

ValidatorType

Gets the type of the validator attribute.

(Inherited from ConfigurationValidatorAttribute)

Applies to

See also