Пример #1
0
        /// <summary>
        /// Save an <see cref="XStreamingElement"/> to a file, optionally formatting.
        /// </summary>
        /// <param name="fileName">Name of file to write content to</param>
        /// <param name="options">
        /// If SaveOptions.DisableFormatting is enabled the output is not indented.
        /// If SaveOptions.OmitDuplicateNamespaces is enabled duplicate namespace declarations will be removed.
        /// </param>
        public void Save(string fileName, SaveOptions options)
        {
            XmlWriterSettings ws = XNode.GetXmlWriterSettings(options);

            using (XmlWriter w = XmlWriter.Create(fileName, ws))
            {
                Save(w);
            }
        }
Пример #2
0
        /// <summary>
        /// Save the contents of an <see cref="XStreamingElement"/> to a text writer
        /// optionally formatting.
        /// </summary>
        /// <param name="textWriter"><see cref="TextWriter"/> to write to </param>
        /// <param name="options">
        /// If SaveOptions.DisableFormatting is enabled the output is not indented.
        /// If SaveOptions.OmitDuplicateNamespaces is enabled duplicate namespace declarations will be removed.
        /// </param>
        public void Save(TextWriter textWriter, SaveOptions options)
        {
            XmlWriterSettings ws = XNode.GetXmlWriterSettings(options);

            using (XmlWriter w = XmlWriter.Create(textWriter, ws))
            {
                Save(w);
            }
        }
Пример #3
0
        /// <summary>
        /// Save the contents of an <see cref="XStreamingElement"/> to a <see cref="Stream"/>,
        /// optionally formatting.
        /// </summary>
        /// <param name="stream"><see cref="Stream"/> to write to </param>
        /// <param name="options">
        /// If SaveOptions.DisableFormatting is enabled the output is not indented.
        /// If SaveOptions.OmitDuplicateNamespaces is enabled duplicate namespace declarations will be removed.
        /// </param>
        public void Save(Stream stream, SaveOptions options)
        {
            XmlWriterSettings ws = XNode.GetXmlWriterSettings(options);

            using (XmlWriter w = XmlWriter.Create(stream, ws))
            {
                Save(w);
            }
        }
        public void Save(string fileName, SaveOptions options)
        {
            XmlWriterSettings xmlWriterSettings = XNode.GetXmlWriterSettings(options);

            using (XmlWriter writer = XmlWriter.Create(fileName, xmlWriterSettings))
            {
                this.Save(writer);
            }
        }
        public void Save(TextWriter textWriter, SaveOptions options)
        {
            XmlWriterSettings xmlWriterSettings = XNode.GetXmlWriterSettings(options);

            using (XmlWriter writer = XmlWriter.Create(textWriter, xmlWriterSettings))
            {
                this.Save(writer);
            }
        }
Пример #6
0
        public void Save(string fileName, SaveOptions options)
        {
            XmlWriterSettings xmlWriterSettings = XNode.GetXmlWriterSettings(options);

            if ((this.declaration != null) && !string.IsNullOrEmpty(this.declaration.Encoding))
            {
                try
                {
                    xmlWriterSettings.Encoding = Encoding.GetEncoding(this.declaration.Encoding);
                }
                catch (ArgumentException)
                {
                }
            }
            using (XmlWriter writer = XmlWriter.Create(fileName, xmlWriterSettings))
            {
                this.Save(writer);
            }
        }