本文整理匯總了C#中System.Xml.Schema.XmlSchemaElement.Validate方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlSchemaElement.Validate方法的具體用法?C# XmlSchemaElement.Validate怎麽用?C# XmlSchemaElement.Validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Schema.XmlSchemaElement
的用法示例。
在下文中一共展示了XmlSchemaElement.Validate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetValidatingReader
private XmlReader GetValidatingReader(XmlReader reader, XmlSchemaSet schemas, ValidationEventHandler validationEvent, XmlSchemaType schemaType, XmlSchemaElement schemaElement, XmlSchemaAttribute schemaAttribute)
{
if (schemaAttribute != null)
{
return schemaAttribute.Validate(reader, null, schemas, validationEvent);
}
if (schemaElement != null)
{
return schemaElement.Validate(reader, null, schemas, validationEvent);
}
if (schemaType != null)
{
return schemaType.Validate(reader, null, schemas, validationEvent);
}
XmlReaderSettings settings = new XmlReaderSettings {
ConformanceLevel = ConformanceLevel.Auto,
ValidationType = ValidationType.Schema,
Schemas = schemas
};
settings.ValidationEventHandler += validationEvent;
return XmlReader.Create(reader, settings);
}
示例2: GetValidatingReader
private XmlReader GetValidatingReader( XmlReader reader, XmlSchemaSet schemas, ValidationEventHandler validationEvent, XmlSchemaType schemaType, XmlSchemaElement schemaElement, XmlSchemaAttribute schemaAttribute ) {
if (schemaAttribute != null) {
return schemaAttribute.Validate(reader, null, schemas, validationEvent);
}
else if (schemaElement != null) {
return schemaElement.Validate(reader, null, schemas, validationEvent);
}
else if (schemaType != null) {
return schemaType.Validate(reader, null, schemas, validationEvent);
}
Debug.Assert( schemas != null, "schemas != null" );
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ConformanceLevel = ConformanceLevel.Auto;
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.Schemas = schemas;
readerSettings.ValidationEventHandler += validationEvent;
return XmlReader.Create( reader, readerSettings );
}