GetSchemaNamespace() public static method

public static GetSchemaNamespace ( int version ) : string
version int
return string
示例#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);
            }
        }
示例#2
0
        public void Save(Stream stream, bool validate, int minimumManifestVersion)
        {
            int version         = Math.Max(minimumManifestVersion, ManifestVersionUtility.GetManifestVersion(Metadata));
            var schemaNamespace = (XNamespace)ManifestSchemaUtility.GetSchemaNamespace(version);

            new XDocument(
                new XElement(schemaNamespace + "package",
                             Metadata.ToXElement(schemaNamespace))).Save(stream);
        }
示例#3
0
        public void Save(Stream stream, bool validate, int minimumManifestVersion)
        {
            if (validate)
            {
                Validate(this);
            }
            string schemaNamespace             = ManifestSchemaUtility.GetSchemaNamespace(Math.Max(minimumManifestVersion, ManifestVersionUtility.GetManifestVersion(this.Metadata)));
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add("", schemaNamespace);
            new XmlSerializer(typeof(Manifest), schemaNamespace).Serialize(stream, this, namespaces);
        }
示例#4
0
        public void Save(Stream stream, bool validate, int minimumManifestVersion)
        {
            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);

            serializer.Serialize(stream, this, ns);
        }
示例#5
0
        public void Save(Stream stream, bool validate, int minimumManifestVersion)
        {
            int version         = Math.Max(minimumManifestVersion, ManifestVersionUtility.GetManifestVersion(Metadata));
            var schemaNamespace = (XNamespace)ManifestSchemaUtility.GetSchemaNamespace(version);

            new XDocument(
                new XElement(schemaNamespace + "package",
                             Metadata.ToXElement(schemaNamespace),
                             Files.Any() ?
                             new XElement(schemaNamespace + "files",
                                          Files.Select(file => new XElement(schemaNamespace + "file",
                                                                            new XAttribute("src", file.Source),
                                                                            new XAttribute("target", file.Target),
                                                                            new XAttribute("exclude", file.Exclude)))) : null)).Save(stream);
        }
示例#6
0
        public void Save(Stream stream, bool validate, int minimumManifestVersion)
        {
            int version         = Math.Max(minimumManifestVersion, ManifestVersionUtility.GetManifestVersion(Metadata));
            var schemaNamespace = (XNamespace)ManifestSchemaUtility.GetSchemaNamespace(version);

            var document = new XDocument(
                new XElement(schemaNamespace + "package",
                             Metadata.ToXElement(schemaNamespace)));

            var fileElement = Files.ToXElement(schemaNamespace);

            if (fileElement != null)
            {
                document.Root.Add(fileElement);
            }

            document.Save(stream);
        }