BlogEngine.Core.SyndicationGenerator.WriteAtomContentCommonElements C# (CSharp) Method

WriteAtomContentCommonElements() private method

Writes the common/shared Atom feed element information to the specified XmlWriter.
private WriteAtomContentCommonElements ( XmlWriter writer ) : void
writer System.Xml.XmlWriter /// The to write channel element information to. ///
return void
        private void WriteAtomContentCommonElements(XmlWriter writer)
        {
            // ------------------------------------------------------------
            // Write optional feed elements
            // ------------------------------------------------------------
            writer.WriteStartElement("author");
            writer.WriteElementString("name", this.Settings.AuthorName);
            writer.WriteEndElement();

            writer.WriteStartElement("generator");
            writer.WriteAttributeString("uri", GeneratorUri.ToString());
            writer.WriteAttributeString("version", GeneratorVersion.ToString());
            writer.WriteString(GeneratorName);
            writer.WriteEndElement();

            // ------------------------------------------------------------
            // Write blogChannel syndication extension elements
            // ------------------------------------------------------------
            Uri blogRoll;
            if (Uri.TryCreate(
                String.Concat(Utils.AbsoluteWebRoot.ToString().TrimEnd('/'), "/opml.axd"),
                UriKind.RelativeOrAbsolute,
                out blogRoll))
            {
                writer.WriteElementString(
                    "blogChannel", "blogRoll", "http://backend.userland.com/blogChannelModule", blogRoll.ToString());
            }

            if (!String.IsNullOrEmpty(this.Settings.Endorsement))
            {
                Uri blink;
                if (Uri.TryCreate(this.Settings.Endorsement, UriKind.RelativeOrAbsolute, out blink))
                {
                    writer.WriteElementString(
                        "blogChannel", "blink", "http://backend.userland.com/blogChannelModule", blink.ToString());
                }
            }

            // ------------------------------------------------------------
            // Write Dublin Core syndication extension elements
            // ------------------------------------------------------------
            if (!String.IsNullOrEmpty(this.Settings.AuthorName))
            {
                writer.WriteElementString("dc", "creator", "http://purl.org/dc/elements/1.1/", this.Settings.AuthorName);
            }

            if (!String.IsNullOrEmpty(this.Settings.Description))
            {
                writer.WriteElementString(
                    "dc", "description", "http://purl.org/dc/elements/1.1/", this.Settings.Description);
            }

            if (!String.IsNullOrEmpty(this.Settings.Language))
            {
                writer.WriteElementString("dc", "language", "http://purl.org/dc/elements/1.1/", this.Settings.Language);
            }

            if (!String.IsNullOrEmpty(this.Settings.Name))
            {
                writer.WriteElementString("dc", "title", "http://purl.org/dc/elements/1.1/", this.Settings.Name);
            }

            // ------------------------------------------------------------
            // Write basic geo-coding syndication extension elements
            // ------------------------------------------------------------
            var decimalFormatInfo = new NumberFormatInfo { NumberDecimalDigits = 6 };

            if (this.Settings.GeocodingLatitude != Single.MinValue)
            {
                writer.WriteElementString(
                    "geo",
                    "lat",
                    "http://www.w3.org/2003/01/geo/wgs84_pos#",
                    this.Settings.GeocodingLatitude.ToString("N", decimalFormatInfo));
            }

            if (this.Settings.GeocodingLongitude != Single.MinValue)
            {
                writer.WriteElementString(
                    "geo",
                    "long",
                    "http://www.w3.org/2003/01/geo/wgs84_pos#",
                    this.Settings.GeocodingLongitude.ToString("N", decimalFormatInfo));
            }
        }