コード例 #1
0
        /// <summary>
        /// Builds the syndication feed from the specified <paramref name="album" /> and write it to the <paramref name="stream" />.
        /// </summary>
        /// <param name="album">The album from which to build the syndication feed.</param>
        /// <param name="stream">The <see cref="T:System.IO.Stream" /> to which to write.</param>
        /// <param name="contentType">Type of the requested content. Examples: "application/atom+xml", "application/rss+xml"</param>
        /// <param name="moBuilderOptions">The options that direct the creation of HTML and URLs for a media object.</param>
        private static void BuildSyndicationFeed(IAlbum album, Stream stream, string contentType, MediaObjectHtmlBuilderOptions moBuilderOptions)
        {
            var fb = new AlbumSyndicationFeedBuilder(album, moBuilderOptions);

            var feed = fb.Generate();

            using (var writer = XmlWriter.Create(stream))
            {
                if (String.Equals(contentType, AtomMediaType, StringComparison.InvariantCultureIgnoreCase))
                {
                    var atomFormatter = new Atom10FeedFormatter(feed);
                    atomFormatter.WriteTo(writer);
                }
                else
                {
                    var rssFormatter = new Rss20FeedFormatter(feed);
                    rssFormatter.WriteTo(writer);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Builds the syndication feed from the specified <paramref name="album" /> and write it to the <paramref name="stream" />.
        /// </summary>
        /// <param name="album">The album from which to build the syndication feed.</param>
        /// <param name="stream">The <see cref="T:System.IO.Stream" /> to which to write.</param>
        /// <param name="contentType">Type of the requested content. Examples: "application/atom+xml", "application/rss+xml"</param>
        /// <param name="moBuilderOptions">The options that direct the creation of HTML and URLs for a media object.</param>
        private static void BuildSyndicationFeed(IAlbum album, Stream stream, string contentType, MediaObjectHtmlBuilderOptions moBuilderOptions)
        {
            var fb = new AlbumSyndicationFeedBuilder(album, moBuilderOptions);

            var feed = fb.Generate();

            using (var writer = XmlWriter.Create(stream))
            {
                if (String.Equals(contentType, AtomMediaType, StringComparison.InvariantCultureIgnoreCase))
                {
                    var atomFormatter = new Atom10FeedFormatter(feed);
                    atomFormatter.WriteTo(writer);
                }
                else
                {
                    var rssFormatter = new Rss20FeedFormatter(feed);
                    rssFormatter.WriteTo(writer);
                }
            }
        }