ElementInformation.Validator 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得用來驗證關聯 ConfigurationElement 物件的物件。
public:
property System::Configuration::ConfigurationValidatorBase ^ Validator { System::Configuration::ConfigurationValidatorBase ^ get(); };
public System.Configuration.ConfigurationValidatorBase Validator { get; }
member this.Validator : System.Configuration.ConfigurationValidatorBase
Public ReadOnly Property Validator As ConfigurationValidatorBase
屬性值
用來驗證關聯 ConfigurationElement 物件的物件。
範例
下列範例將示範如何使用 Validator 屬性。
static public void GetElementValidator()
{
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the section.
UrlsSection section =
(UrlsSection)config.GetSection("MyUrls");
// Get the element.
UrlConfigElement url = section.Simple;
// Get the element source file.
ConfigurationValidatorBase elValidator =
url.ElementInformation.Validator;
Console.WriteLine("Url element validator: {0}",
elValidator.ToString());
}
Public Shared Sub GetElementValidator()
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
' Get the element.
Dim url As UrlConfigElement = _
section.Simple
' Get the element source file.
Dim elValidator _
As ConfigurationValidatorBase = _
url.ElementInformation.Validator
Console.WriteLine("Url element validator: {0}", _
elValidator.ToString())
End Sub
備註
不需要驗證程式物件,而且這個屬性可能會傳回 null
。