NuGet.ManifestVersionUtility.GetManifestVersion C# (CSharp) Method

GetManifestVersion() public static method

public static GetManifestVersion ( ManifestMetadata metadata ) : int
metadata ManifestMetadata
return int
        public static int GetManifestVersion(ManifestMetadata metadata)
        {
            return Math.Max(VisitObject(metadata), GetVersionPropertyVersion(metadata));
        }

Usage Example

Exemplo n.º 1
0
        public void Save(Stream stream, bool validate, int minimumManifestVersion)
        {
            if (validate)
            {
                // Validate before saving
                Validate(this);
            }

            int    version         = Math.Max(minimumManifestVersion, ManifestVersionUtility.GetManifestVersion(Metadata));
            string schemaNamespace = ManifestSchemaUtility.GetSchemaNamespace(version);

            // Define the namespaces to use when serializing
            var ns = new XmlSerializerNamespaces();

            ns.Add("", schemaNamespace);

            // Need to force the namespace here again as the default in order to get the XML output clean
            var serializer = new XmlSerializer(typeof(Manifest), schemaNamespace);

            using (var xmlWriter = new XmlTextWriter(stream, Encoding.UTF8))
            {
                xmlWriter.Indentation = 4;
                xmlWriter.Formatting  = Formatting.Indented;
                serializer.Serialize(xmlWriter, this, ns);
            }
        }
All Usage Examples Of NuGet.ManifestVersionUtility::GetManifestVersion