Ejemplo n.º 1
0
        private static void ValidateManifestSchema(XDocument document, string schemaNamespace)
        {
#if !IS_CORECLR // CORECLR_TODO: XmlSchema
            var schemaSet = ManifestSchemaUtility.GetManifestSchemaSet(schemaNamespace);

            document.Validate(schemaSet, (sender, e) =>
            {
                if (e.Severity == XmlSeverityType.Error)
                {
                    var message = e.Message;

                    // To make sure this error message is actionable, try to add the element name
                    // where the error is occurring.
                    var senderElement = sender as XElement;
                    if (senderElement != null)
                    {
                        message = string.Format(
                            CultureInfo.CurrentCulture,
                            Strings.InvalidNuspecElement,
                            message,
                            senderElement.Name.LocalName);
                    }

                    // Throw an exception if there is a validation error
                    throw new InvalidOperationException(message);
                }
            });
#endif
        }
Ejemplo n.º 2
0
        private static void ValidateManifestSchema(XDocument document, string schemaNamespace)
        {
#if !IS_CORECLR // CORECLR_TODO: XmlSchema
            var schemaSet = ManifestSchemaUtility.GetManifestSchemaSet(schemaNamespace);

            document.Validate(schemaSet, (sender, e) =>
            {
                if (e.Severity == XmlSeverityType.Error)
                {
                    // Throw an exception if there is a validation error
                    throw new InvalidOperationException(e.Message);
                }
            });
#endif
        }