NuGet.ManifestSchemaUtility.IsKnownSchema C# (CSharp) Method

IsKnownSchema() public static method

public static IsKnownSchema ( string schemaNamespace ) : bool
schemaNamespace string
return bool
        public static bool IsKnownSchema(string schemaNamespace)
        {
            return VersionToSchemaMappings.Contains(schemaNamespace, StringComparer.OrdinalIgnoreCase);
        }

Usage Example

Exemplo n.º 1
0
        private static void CheckSchemaVersion(XDocument document)
        {
#if NET45 // CORECLR_TODO: XmlSchema
            // Get the metadata node and look for the schemaVersion attribute
            XElement metadata = GetMetadataElement(document);

            if (metadata != null)
            {
                // Yank this attribute since we don't want to have to put it in our xsd
                XAttribute schemaVersionAttribute = metadata.Attribute(SchemaVersionAttributeName);

                if (schemaVersionAttribute != null)
                {
                    schemaVersionAttribute.Remove();
                }

                // Get the package id from the metadata node
                string packageId = GetPackageId(metadata);

                // If the schema of the document doesn't match any of our known schemas
                if (!ManifestSchemaUtility.IsKnownSchema(document.Root.Name.Namespace.NamespaceName))
                {
                    throw new InvalidOperationException(
                              String.Format(CultureInfo.CurrentCulture,
                                            NuGetResources.IncompatibleSchema,
                                            packageId,
                                            typeof(Manifest).Assembly.GetName().Version));
                }
            }
#endif
        }
All Usage Examples Of NuGet.ManifestSchemaUtility::IsKnownSchema