本文整理汇总了C#中System.ServiceModel.Syndication.Rss20FeedFormatter.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:C# Rss20FeedFormatter.WriteTo方法的具体用法?C# Rss20FeedFormatter.WriteTo怎么用?C# Rss20FeedFormatter.WriteTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Syndication.Rss20FeedFormatter
的用法示例。
在下文中一共展示了Rss20FeedFormatter.WriteTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getXmlContent
private Action<Stream> getXmlContent(IEnumerable<BlogPost> model)
{
var items = model.Select(post =>
new SyndicationItem(
title: post.Title,
content: post.Content,
itemAlternateLink: new Uri(BaseUrl + post.GetLink().TrimStart('/')),
id: post.Id,
lastUpdatedTime: post.PubDate)
{
PublishDate = post.PubDate,
Summary = new TextSyndicationContent(post.Content, TextSyndicationContentKind.Html)
})
.ToList();
var feed = new SyndicationFeed(RssTitle, RssTitle, BaseUrl, items);
var formatter = new Rss20FeedFormatter(feed);
return stream =>
{
using (var writer = XmlWriter.Create(stream))
{
formatter.WriteTo(writer);
}
};
}
示例2: Index
public async Task<ActionResult> Index()
{
var posts = await Task.Run(() => MvcApplication.Posts);
var feed = new SyndicationFeed("invokecommand.net", "All blog posts", new Uri(this.ServerUrl("/rss.xml")), "1", DateTime.Now)
{
Items = posts.Select(
post => new SyndicationItem(
post.Title,
post.Summary,
new Uri(this.ServerUrl(post.Url.ToString())),
post.Name,
post.Published))
.ToList()
};
var formatter = new Rss20FeedFormatter(feed);
var content = new StringBuilder();
using (var writer = XmlWriter.Create(content))
{
formatter.WriteTo(writer);
writer.Flush();
}
return Content(content.ToString(), "text/xml");
}
示例3: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
SyndicationFeedFormatter formatter;
string contentType;
switch (_feedType)
{
case FeedType.Atom:
formatter = new Atom10FeedFormatter(_syndicationFeed);
contentType = "application/atom+xml";
break;
case FeedType.Rss:
formatter = new Rss20FeedFormatter(_syndicationFeed);
contentType = "application/rss+xml";
break;
default:
throw new NotImplementedException("Feed type not accounted for");
}
context.HttpContext.Response.ContentType = contentType;
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
formatter.WriteTo(writer);
}
}
示例4: fload
public void fload(string namefile)
{
var lines = System.IO.File.ReadAllLines(namefile);
feed.Title = new TextSyndicationContent(lines[1]);
feed.Copyright = new TextSyndicationContent(lines[2]);
feed.Description = new TextSyndicationContent(lines[3]);
feed.Generator = lines[4];
SyndicationLink link = new SyndicationLink();
link.Uri = new Uri(lines[5]);
feed.Links.Add(link);
feed.Items = txtgotolv("feedinfo.txt");
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
XmlWriter Writer = XmlWriter.Create
(Response.Output);
if (lines[0] == "rss")
{
Rss20FeedFormatter Formatter = new Rss20FeedFormatter(feed);
Formatter.WriteTo(Writer);
}
else
{
if (lines[0] == "atom")
{
Atom10FeedFormatter Formatter = new Atom10FeedFormatter(feed);
Formatter.WriteTo(Writer);
}
}
Writer.Close();
Response.End();
}
示例5: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/atom+xml";
//check request is for Atom or RSS
if (context.HttpContext.Request.QueryString["type"] != null && context.HttpContext.Request.QueryString["type"].ToString().ToLower() == "atom")
{
//Atom Feed
context.HttpContext.Response.ContentType = "application/atom+xml";
var rssFormatter = new Atom10FeedFormatter(FeedData);
using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true }))
{
rssFormatter.WriteTo(writer);
}
}
else
{
//RSS Feed
context.HttpContext.Response.ContentType = "application/rss+xml";
var rssFormatter = new Rss20FeedFormatter(FeedData);
using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true }))
{
rssFormatter.WriteTo(writer);
}
}
}
示例6: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
List<SyndicationItem> syndicationItems = new List<SyndicationItem>();
IList<Card> cards = uWiMP.TVServer.Cards.GetCards();
foreach (Card card in cards)
{
if (card.Enabled & card.Name.ToLower().Contains("builtin"))
{
uWiMP.TVServer.Cards.Status status = uWiMP.TVServer.Cards.GetCardStatus(card);
SyndicationItem si = new SyndicationItem();
si.Title = new TextSyndicationContent("Recording");
}
}
SyndicationFeed feed = new SyndicationFeed(syndicationItems);
StringWriter output = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(output);
Rss20FeedFormatter f = new Rss20FeedFormatter(feed);
f.WriteTo(writer);
Context.Response.ContentType = "application/rss+xml";
Context.Response.Write(output.ToString());
}
示例7: WriteFile
protected override void WriteFile(System.Web.HttpResponseBase response)
{
var items = new List<SyndicationItem>();
foreach (Dinner d in this.Dinners)
{
string contentString = String.Format("{0} with {1} on {2:MMM dd, yyyy} at {3}. Where: {4}, {5}",
d.Description, d.HostedBy, d.EventDate, d.EventDate.ToShortTimeString(), d.Address, d.Country);
var item = new SyndicationItem(
title: d.Title,
content: contentString,
itemAlternateLink: new Uri("http://nrddnr.com/" + d.DinnerId),
id: "http://nrddnr.com/" + d.DinnerId,
lastUpdatedTime: d.EventDate.ToUniversalTime()
);
item.PublishDate = d.EventDate.ToUniversalTime();
item.Summary = new TextSyndicationContent(contentString, TextSyndicationContentKind.Plaintext);
items.Add(item);
}
SyndicationFeed feed = new SyndicationFeed(
this.Title,
this.Title, /* Using Title also as Description */
currentUrl,
items);
Rss20FeedFormatter formatter = new Rss20FeedFormatter(feed);
using (XmlWriter writer = XmlWriter.Create(response.Output))
{
formatter.WriteTo(writer);
}
}
示例8: WriteFile
protected override void WriteFile(HttpResponseBase response)
{
var rssFormatter = new Rss20FeedFormatter(Feed);
using (var writer = XmlWriter.Create(response.Output))
rssFormatter.WriteTo(writer);
response.End();
}
示例9: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
Rss20FeedFormatter formatter = new Rss20FeedFormatter(this.Feed);
using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
formatter.WriteTo(writer);
}
}
示例10: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = MimeTypes.ApplicationRssXml;
var rssFormatter = new Rss20FeedFormatter(Feed);
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
rssFormatter.WriteTo(writer);
}
}
示例11: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = Constants.RssContentType;
Rss20FeedFormatter rss = new Rss20FeedFormatter(Feed);
using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
rss.WriteTo(writer);
}
}
示例12: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
var rssFormatter = new Rss20FeedFormatter(_feed, false);
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true }))
{
rssFormatter.WriteTo(writer);
}
}
示例13: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
var response = context.HttpContext.Response;
response.ContentType = "application/rss+xml";
var rssFormatter = new Rss20FeedFormatter(Feed);
using (var writer = XmlWriter.Create(response.Output))
{
// Feed là nguồn dữ liệu. Thao tác ở đây là lấy nguồn dữ liệu Feed ghi ra response dưới dạng RSS
rssFormatter.WriteTo(writer);
}
}
示例14: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
var feed = new SyndicationFeed(Title, Description, Link);
var formatter = new Rss20FeedFormatter();
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
formatter.WriteTo(writer);
}
}
示例15: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
if (Feed == null) throw new ArgumentNullException("Feed");
var formater = new Rss20FeedFormatter(Feed);
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
formater.WriteTo(writer);
}
}