本文整理汇总了C#中System.ServiceModel.Syndication.SyndicationFeed类的典型用法代码示例。如果您正苦于以下问题:C# SyndicationFeed类的具体用法?C# SyndicationFeed怎么用?C# SyndicationFeed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyndicationFeed类属于System.ServiceModel.Syndication命名空间,在下文中一共展示了SyndicationFeed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformFeed
public void TransformFeed(SyndicationFeed feed, SyndicationVisitorContext context)
{
if (feed.Links.Any())
{
feed.Links[0] = new SyndicationLink(context.RssUrl, "alternate", title: null, mediaType: null, length: 0);
}
}
示例2: GetService
public async Task<IHttpActionResult> GetService(string id)
{
Service service = await db.Services.FindAsync(id);
if (service == null)
{
return NotFound();
}
var ServiceFeed = new SyndicationFeed();
ServiceFeed.Id = service.Id;
ServiceFeed.LastUpdatedTime = service.Updated;
ServiceFeed.Title = new TextSyndicationContent(service.Title);
ServiceFeed.Description = new TextSyndicationContent(service.Summary);
ServiceFeed.Categories.Add(new SyndicationCategory(service.ServiceCategoryId.ToString(), null, service.Category.Name));
var SelfLink = new SyndicationLink();
SelfLink.RelationshipType = "self";
SelfLink.Uri = new Uri(Url.Content("~/Service/" + service.Id));
SelfLink.MediaType = "application/atom+xml";
ServiceFeed.Links.Add(SelfLink);
var HtmlLink = new SyndicationLink();
HtmlLink.RelationshipType = "self";
HtmlLink.Uri = new Uri("http://surreyhillsdc.azurewebsites.net/");
HtmlLink.MediaType = "text/html";
ServiceFeed.Links.Add(HtmlLink);
return Ok(ServiceFeed.GetAtom10Formatter());
}
示例3: GetSyndicationFeed
/// <summary>
/// Turn a SimpleFeed object into a SyndicationFeed object
/// </summary>
private SyndicationFeed GetSyndicationFeed(SimpleFeed pFeed)
{
var feed = new SyndicationFeed();
var items = new List<SyndicationItem>();
feed.BaseUri = new Uri(pFeed.BaseUrl);
if (!string.IsNullOrWhiteSpace(pFeed.Title))
feed.Title = new TextSyndicationContent(pFeed.Title);
if (!string.IsNullOrWhiteSpace(pFeed.Description))
feed.Description = new TextSyndicationContent(pFeed.Description);
if (!string.IsNullOrWhiteSpace(pFeed.Language))
feed.Language = pFeed.Language;
if (pFeed.Entries != null)
{
foreach (var entry in pFeed.Entries)
{
var item = new SyndicationItem(entry.Title, entry.Body, entry.TitleLinkUri);
//Id, DatePublished, DateLastUpdated are required so that each new post won't make readers think that every entry is new
item.Id = entry.Id;
item.PublishDate = entry.DatePublished;
item.LastUpdatedTime = entry.DateLastUpdated;
item.BaseUri = entry.TitleLinkUri;
items.Add(item);
}
}
feed.Items = items;
return feed;
}
示例4: ActivityFeed
public ActionResult ActivityFeed(string name, int id)
{
var polfeed = _polRep.LatestFeed(id, includeposts);
List<SyndicationItem> items = new List<SyndicationItem>();
var pol = _polRep.GetPoliticianById(id);
var polLink = this.Request.Url.GetLeftPart(UriPartial.Authority) + pol.PolLink(this);
SyndicationFeed feed =
new SyndicationFeed(
String.Format("{0} Feed", pol.FullName()), "Activity Feed på Folkets Ting",
new Uri(Request.Url.ToString()),
Request.Url.AbsoluteUri,
polfeed.Last().date);
foreach (var feeditem in polfeed)
{
var link = (this.Request.Url.GetLeftPart(UriPartial.Authority) + feeditem.ActionUrl);
SyndicationItem item =
new SyndicationItem(feeditem.ActionText,
feeditem.BodyText,
new Uri(link),
feeditem.ActionUrl + feeditem.ActionText,
feeditem.date);
items.Add(item);
}
feed.Items = items;
return new RssActionResult() { Feed = feed };
}
示例5: GlobalEquityWindow
public GlobalEquityWindow()
{
this.InitializeComponent();
Image img = Properties.Resources.standardandpoors;
this.logoBox.Image = img;
this.dataExtraction = new DataExtraction();
this.feedCondent = new SyndicationFeed();
this.links = new Dictionary<DateTime, string>();
this.feedCondent = this.dataExtraction.GetRssFeedData("https://us.spindices.com/rss/rss-details/?rssFeedName=global-equity");
if (this.feedCondent != null)
{
Tuple<DataGridView, Dictionary<DateTime, string>> parsedContent =
this.dataExtraction.ParseRssFeedData(this.feedCondent);
foreach (DataGridViewRow row in parsedContent.Item1.Rows)
{
int rowId = this.dataGridContent.Rows.Add();
this.dataGridContent.Rows[rowId].Cells[0].Value = row.Cells[0].Value;
this.dataGridContent.Rows[rowId].Cells[1].Value = row.Cells[1].Value;
this.dataGridContent.Rows[rowId].Cells[2].Value = row.Cells[2].Value;
}
this.links = parsedContent.Item2;
}
this.dataGridContent.Sort(this.dataGridContent.Columns[0], ListSortDirection.Descending);
}
示例6: Build
public string Build(FeedData dataFeed, Uri baseUri)
{
var feed = new SyndicationFeed
{
Id = dataFeed.Id.ToString(),
LastUpdatedTime = dataFeed.DateCreated,
Items = dataFeed.Messages.Select(x => new SyndicationItem
{
Content = new RawSyndicationContent(x.Body),
Id = x.Id.ToString(),
LastUpdatedTime = x.CreatedAt
})
};
if (!string.IsNullOrEmpty(dataFeed.NextUri))
feed.Links.Add(new SyndicationLink(new Uri(baseUri, dataFeed.NextUri), NextInArchiveRelationshipType,
"Next In Archive", ContentType, 0));
if (!string.IsNullOrEmpty(dataFeed.PreviousUri))
feed.Links.Add(new SyndicationLink(new Uri(baseUri, dataFeed.PreviousUri), PrevInArchiveRelationshipType,
"Previous In Archive", ContentType, 0));
var formatter = new Atom10FeedFormatter(feed);
var sw = new StringWriter();
using (var writer = XmlWriter.Create(sw))
{
formatter.WriteTo(writer);
}
return sw.ToString();
}
示例7: CreateFeed
public SyndicationFeedFormatter CreateFeed()
{
// Create a new Syndication Feed.
SyndicationFeed feed = new SyndicationFeed("Feed Title", "A WCF Syndication Feed", null);
List<SyndicationItem> items = new List<SyndicationItem>();
// Create a new Syndication Item.
SyndicationItem item = new SyndicationItem("An item", "Item content", null);
items.Add(item);
feed.Items = items;
// Return ATOM or RSS based on query string
// rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/
// atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
SyndicationFeedFormatter formatter = null;
if (query == "atom")
{
formatter = new Atom10FeedFormatter(feed);
}
else
{
formatter = new Rss20FeedFormatter(feed);
}
return formatter;
}
示例8: CreateFeed
public SyndicationFeedFormatter CreateFeed()
{
// Créez un flux RSS.
SyndicationFeed feed = new SyndicationFeed("Bug Track", "Flux rss du bug track", null);
List<SyndicationItem> items = new List<SyndicationItem>();
// Créez un article RSS.
List<DBO.Bug> bugs = DataAccess.Bug.GetLastBug(10);
bugs.ForEach(bug => items.Add(new SyndicationItem(bug.Title, bug.Details, null)));
feed.Items = items;
// Renvoie ATOM ou RSS en fonction de la chaîne de requête
// rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/
// atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/?format=atom
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
SyndicationFeedFormatter formatter = null;
if (query == "atom")
{
formatter = new Atom10FeedFormatter(feed);
}
else
{
formatter = new Rss20FeedFormatter(feed);
}
return formatter;
}
示例9: SyndicationFeedActionResult
public SyndicationFeedActionResult(SyndicationFeed result)
{
if (result == null)
throw new ArgumentNullException("result");
Result = result;
}
示例10: CreateFeed
public SyndicationFeedFormatter CreateFeed()
{
// Créez un flux RSS.
SyndicationFeed feed = new SyndicationFeed("TekConf Event", "Last 10 event added in TekConf", null);
List<SyndicationItem> items = TekConf.DataAccess.Event.GetLastEventsList(10).Select(
e => new SyndicationItem("idEvent : " + e.id + " : " + e.name,
e.location + ", " + e.time + " \n " + e.Technology + " \n " + e.description,
null)
).ToList();
feed.Items = items;
// Renvoie ATOM ou RSS en fonction de la chaîne de requête
// rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/
// atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
SyndicationFeedFormatter formatter = null;
if (query == "atom")
{
formatter = new Atom10FeedFormatter(feed);
}
else
{
formatter = new Rss20FeedFormatter(feed);
}
return formatter;
}
示例11: WriteXml
internal override void WriteXml(XmlWriter writer, SyndicationFeed feed)
{
writer.WriteStartElement(FeedName, FeedNamespace);
if (!String.IsNullOrEmpty(feed.Language))
writer.WriteAttributeString("xml:lang", feed.Language);
WriteXml(writer, feed.Title, "title", true);
writer.WriteElementString("id", feed.Id);
WriteXml(writer, feed.Copyright, "rights");
string updated = feed.LastUpdatedTime.ToUniversalTime().ToString("s");
writer.WriteElementString("updated", updated + "Z");
if (feed.ImageUrl != null)
writer.WriteElementString("logo", feed.ImageUrl.ToString());
if (!String.IsNullOrEmpty(feed.Generator))
writer.WriteElementString("generator", feed.Generator);
WriteXml(writer, feed.Description, "summary");
foreach (SyndicationItem item in feed.Items)
{
WriteTo(writer, item);
}
writer.WriteEndElement();
}
示例12: Write
/// <summary>
/// Executes the syndication result on the given context.
/// </summary>
/// <param name="context">The current context.</param>
public virtual void Write(IStreamResponse response) {
var writer = new XmlTextWriter(response.OutputStream, Encoding.UTF8);
var ui = new Client.Helpers.UIHelper();
// Write headers
response.ContentType = ContentType;
response.ContentEncoding = Encoding.UTF8;
var feed = new SyndicationFeed() {
Title = new TextSyndicationContent(Config.Site.Title),
LastUpdatedTime = Posts.First().Published.Value,
Description = new TextSyndicationContent(Config.Site.Description),
};
feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/"))));
var items = new List<SyndicationItem>();
foreach (var post in Posts) {
var item = new SyndicationItem() {
Title = SyndicationContent.CreatePlaintextContent(post.Title),
PublishDate = post.Published.Value,
Summary = SyndicationContent.CreateHtmlContent(post.Body)
};
item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/" + post.Type.Slug + "/" + post.Slug))));
items.Add(item);
}
feed.Items = items;
var formatter = GetFormatter(feed);
formatter.WriteTo(writer);
writer.Flush();
writer.Close();
}
示例13: Rss
public ActionResult Rss(string domain="")
{
var news = NewsProvider.GetSeason(2014, domain).OrderByDescending(n=>n.Date).Take(10);
var feedItems = new List<SyndicationItem>();
foreach (var news_item in news)
{
var item = new SyndicationItem()
{
Title = TextSyndicationContent.CreatePlaintextContent(news_item.Title),
PublishDate = new DateTimeOffset(news_item.Date),
Summary = TextSyndicationContent.CreateHtmlContent(CombineBriefWithImage(news_item)),
};
string url = "http://afspb.org.ru/news/" + news_item.Slug;
var link = new SyndicationLink(new Uri(url));
link.Title = "Перейти к новости";
item.Links.Add(link);
feedItems.Add(item);
}
var feed = new SyndicationFeed(
"Новости сайта Автомобильной Федерации Санкт-Петербурга и Ленинградской области",
"",
new Uri("http://afspb.org.ru/news/Rss"),
feedItems);
return new RssResult()
{
Feed = feed
};
}
示例14: CreateFeedForBlog
public SyndicationFeedFormatter CreateFeedForBlog(string user, string blog)
{
SyndicationFeed feed = new SyndicationFeed("Blog feed", "A feed linked to a blog", null);
List<SyndicationItem> items = new List<SyndicationItem>();
List<Dbo.RssArticle> articles = BusinessManagement.Feed.GetBlogContent(user, blog);
foreach (Dbo.RssArticle article in articles)
{
SyndicationItem item = new SyndicationItem(article.Title, article.Content, null);
item.PublishDate = article.CreationDate;
items.Add(item);
}
feed.Items = items;
// Renvoie ATOM ou RSS en fonction de la chaîne de requête
// rss -> http://localhost:8733/Design_Time_Addresses/FluxRss/Feed1/
// atom -> http://localhost:8733/Design_Time_Addresses/FluxRss/Feed1/?format=atom
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
SyndicationFeedFormatter formatter = null;
if (query == "atom")
{
formatter = new Atom10FeedFormatter(feed);
}
else
{
formatter = new Rss20FeedFormatter(feed);
}
return formatter;
}
示例15: FeedActionResult
/// <summary>
/// Initializes a new instance of the FeedActionResult class
/// </summary>
/// <param name="blogName">Name of the blog</param>
/// <param name="description">Feed description</param>
/// <param name="format">Format of the feed</param>
/// <param name="url">A URL Helper</param>
/// <param name="posts">The posts to include in the feed</param>
public FeedActionResult(string blogName, string description, FeedFormat format, UrlHelper url, IEnumerable<BlogPost> posts)
{
Guid blogPostId;
string postRelative;
SyndicationItem item;
List<SyndicationItem> items = new List<SyndicationItem>();
// Specify the type of feed
Format = format;
// Initialize the current feed
Feed = new SyndicationFeed(blogName, description, new Uri(url.RouteUrl("Default"), UriKind.Relative));
//load the posts as items
foreach (BlogPost post in posts)
{
blogPostId = post.BlogPostId;
postRelative = url.Action(
"Details", "Posts",
new
{
year = post.PostedDate.Value.Year,
month = post.PostedDate.Value.Month,
day = post.PostedDate.Value.Day,
id = blogPostId
});
item = new SyndicationItem(post.Title, post.Post,
new Uri(postRelative, UriKind.Relative), post.BlogPostId.ToString(), post.PostedDate.Value);
items.Add(item);
}
Feed.Items = items.OrderByDescending(x => x.LastUpdatedTime);
}