System.Xml.DocumentXPathNavigator.CheckValidity C# (CSharp) Méthode

CheckValidity() public méthode

public CheckValidity ( XmlSchemaSet schemas, ValidationEventHandler validationEventHandler ) : bool
schemas System.Xml.Schema.XmlSchemaSet
validationEventHandler ValidationEventHandler
Résultat bool
        public override bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler) {
            XmlDocument ownerDocument;

            if (source.NodeType == XmlNodeType.Document) {
                ownerDocument = (XmlDocument)source;
            }
            else {
                ownerDocument = source.OwnerDocument;

                if (schemas != null) {
                    throw new ArgumentException(Res.GetString(Res.XPathDocument_SchemaSetNotAllowed, null));
                }
            }
            if (schemas == null && ownerDocument != null) {
                schemas = ownerDocument.Schemas;
            }

            if (schemas == null || schemas.Count == 0) {
                throw new InvalidOperationException(Res.GetString(Res.XmlDocument_NoSchemaInfo));
            }

            DocumentSchemaValidator validator = new DocumentSchemaValidator(ownerDocument, schemas, validationEventHandler);
            validator.PsviAugmentation = false;
            return validator.Validate(source);
        }