<image> is an optional sub-element of <channel>, which contains three required and three optional sub-elements.
        /// <summary>
        /// Builds the RSS channel starting XML section.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="url">The url.</param>
        /// <param name="authorEmail">The author email.</param>
        /// <param name="description">The description.</param>
        /// <param name="lang">The lang.</param>
        /// <param name="copyright">The copyright.</param>
        /// <param name="cclicense">The cclicense.</param>
        /// <param name="image">An optional sub-element of channel for rendering an image for the channel.</param>
        protected void BuildChannel(string title, Uri url, string authorEmail, string description, string lang,
                                    string copyright, string cclicense, RssImageElement image)
        {
            //Required Channel Elements
            WriteElementString("title", HtmlHelper.RemoveHtml(title));
            WriteElementString("link", url.ToString());
            WriteElementString("description", HtmlHelper.RemoveHtml(description));

            //Optional Channel Elements
            WriteElementString("language", lang);
            //TODO: Implement this element.
            WriteElementString("copyright", copyright);

            if (!string.IsNullOrEmpty(authorEmail) &&
                authorEmail.IndexOf("@") > 0 &&
                authorEmail.IndexOf(".") > 0 &&
                (Blog.ShowEmailAddressInRss))
            {
                WriteElementString("managingEditor", authorEmail);
            }

            //TODO: <category>One or more categories</category>
            WriteElementString("generator", VersionInfo.VersionDisplayText);

            if (!string.IsNullOrEmpty(cclicense))
            {
                WriteElementString("creativeCommons:license", cclicense);
            }

            if (image != null)
            {
                image.WriteToXmlWriter(this);
            }
        }
        /// <summary>
        /// Writes the channel.
        /// </summary>
        protected virtual void WriteChannel()
        {
            var blogUrl = new Uri(UrlHelper.BlogUrl().ToFullyQualifiedUrl(Blog), "Default.aspx");
            var image   = new RssImageElement(GetRssImage(), Blog.Title, blogUrl, 77, 60, null);

            BuildChannel(Blog.Title, blogUrl, Blog.Email, Blog.SubTitle, Blog.Language, Blog.Author, Blog.LicenseUrl,
                         image);
        }
Пример #3
0
        /// <summary>
        /// Writes the RSS channel to the underlying stream.
        /// </summary>
        protected override void WriteChannel()
        {
            Uri entryUrl = UrlHelper.EntryUrl(CommentEntry).ToFullyQualifiedUrl(Blog);
            var image    = new RssImageElement(GetRssImage(), CommentEntry.Title, entryUrl, 77, 60, null);

            BuildChannel(CommentEntry.Title,
                         entryUrl,
                         CommentEntry.Email,
                         CommentEntry.HasDescription ? CommentEntry.Description : CommentEntry.Body,
                         Blog.Language,
                         Blog.Author,
                         Blog.LicenseUrl,
                         image);
        }