public WriteFeed ( SyndicationFormat format, Stream stream, List |
||
format | SyndicationFormat |
/// A |
stream | Stream |
/// The |
publishables | List |
/// The collection of |
title | string | /// The title of the RSS channel /// |
return | void |
public void WriteFeed(SyndicationFormat format, Stream stream, List<IPublishable> publishables, string title)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (publishables == null)
{
throw new ArgumentNullException("publishables");
}
if (!stream.CanWrite)
{
throw new ArgumentException(
String.Format(
null,
"Unable to generate {0} syndication feed. The provided stream does not support writing.",
format),
"stream");
}
// ------------------------------------------------------------
// Write syndication feed based on specified format
// ------------------------------------------------------------
switch (format)
{
case SyndicationFormat.Atom:
this.WriteAtomFeed(stream, publishables, title);
break;
case SyndicationFormat.Rss:
this.WriteRssFeed(stream, publishables, title);
break;
}
}
/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that implements /// the <see cref="T:System.Web.IHttpHandler"></see> interface. /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext"></see> object that provides references /// to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests. /// </param> public void ProcessRequest(HttpContext context) { string title = RetrieveTitle(context); SyndicationFormat format = RetrieveFormat(context); List<IPublishable> list = GenerateItemList(context); list = CleanList(list); if (string.IsNullOrEmpty(context.Request.QueryString["post"])) { // Shorten the list to the number of posts stated in the settings, except for the comment feed. int max = Math.Min(BlogSettings.Instance.PostsPerFeed, list.Count); list = list.FindAll(delegate(IPublishable item) { return item.IsVisible == true; }); list = list.GetRange(0, max); } SetHeaderInformation(context, list, format); if (BlogSettings.Instance.EnableHttpCompression) HttpModules.CompressionModule.CompressResponse(context); SyndicationGenerator generator = new SyndicationGenerator(BlogSettings.Instance, Category.Categories); generator.WriteFeed(format, context.Response.OutputStream, list, title); }