.NET Framework Class Library
RegexStringValidatorAttribute.ValidatorInstance Property
Gets an instance of the RegexStringValidator class.
Assembly: System.Configuration (in System.Configuration.dll)
Syntax
Visual Basic
Public Overrides ReadOnly Property ValidatorInstance As ConfigurationValidatorBase Get
C#
public override ConfigurationValidatorBase ValidatorInstance { get; }
Visual C++
public: virtual property ConfigurationValidatorBase^ ValidatorInstance { ConfigurationValidatorBase^ get () override; }
F#
abstract ValidatorInstance : ConfigurationValidatorBase override ValidatorInstance : ConfigurationValidatorBase
Property Value
Type: System.Configuration.ConfigurationValidatorBaseThe ConfigurationValidatorBase validator instance.
Remarks
You use the ValidatorInstance property to perform string validation by calling its Validate method.
Examples
The following example shows how to use the ValidatorInstance method.
Visual Basic
Dim valBase As _
ConfigurationValidatorBase
Dim rstrValAttr As _
New RegexStringValidatorAttribute("\w+\S*")
' Get the regular expression string.
Dim regex As String = _
rstrValAttr.Regex
Console.WriteLine( _
"Regular expression: {0}", regex)
Dim badValue As _
String = "&%$bbb"
Dim goodValue As _
String = "filename.txt"
Try
valBase = rstrValAttr.ValidatorInstance
valBase.Validate(goodValue)
' valBase.Validate(badValue);
Catch e As ArgumentException
' Display error message.
Dim msg As String = e.ToString()
#If DEBUG Then
Console.WriteLine(msg)
#End If
End Try '
C#
ConfigurationValidatorBase valBase;
RegexStringValidatorAttribute rstrValAttr =
new RegexStringValidatorAttribute(@"\w+\S*");
// Get the regular expression string.
string regex = rstrValAttr.Regex;
Console.WriteLine("Regular expression: {0}", regex);
string badValue = "&%$bbb";
string goodValue = "filename.txt";
try
{
valBase = rstrValAttr.ValidatorInstance;
valBase.Validate(goodValue);
// valBase.Validate(badValue);
}
catch (ArgumentException e)
{
// Display error message.
string msg = e.ToString();
#if DEBUG
Console.WriteLine(msg);
#endif
}
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also