本文整理汇总了C#中System.ServiceModel.Syndication.SyndicationFeed.AddYahooMediaNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# SyndicationFeed.AddYahooMediaNamespace方法的具体用法?C# SyndicationFeed.AddYahooMediaNamespace怎么用?C# SyndicationFeed.AddYahooMediaNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Syndication.SyndicationFeed
的用法示例。
在下文中一共展示了SyndicationFeed.AddYahooMediaNamespace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFeed
/// <summary>
/// Gets the feed containing meta data about the feed and the feed entries.
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> signifying if the request is cancelled.</param>
/// <returns>A <see cref="SyndicationFeed"/>.</returns>
public async Task<SyndicationFeed> GetFeed(CancellationToken cancellationToken)
{
SyndicationFeed feed = new SyndicationFeed()
{
// id (Required) - The feed universally unique identifier.
Id = FeedId,
// title (Required) - Contains a human readable title for the feed. Often the same as the title of the
// associated website. This value should not be blank.
Title = SyndicationContent.CreatePlaintextContent("ASP.NET MVC Boilerplate"),
// items (Required) - The items to add to the feed.
Items = await this.GetItems(cancellationToken),
// subtitle (Recommended) - Contains a human-readable description or subtitle for the feed.
Description = SyndicationContent.CreatePlaintextContent(
"This is the ASP.NET MVC Boilerplate feed description."),
// updated (Optional) - Indicates the last time the feed was modified in a significant way.
LastUpdatedTime = DateTimeOffset.Now,
// logo (Optional) - Identifies a larger image which provides visual identification for the feed.
// Images should be twice as wide as they are tall.
ImageUrl = new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-logo-96x48.png")),
// rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the feed.
Copyright = SyndicationContent.CreatePlaintextContent(
string.Format("© {0} - {1}", DateTime.Now.Year, Application.Name)),
// lang (Optional) - The language of the feed.
Language = "en-GB",
// generator (Optional) - Identifies the software used to generate the feed, for debugging and other
// purposes. Do not put in anything that identifies the technology you are using.
// Generator = "Sample Code",
// base (Buggy) - Add the full base URL to the site so that all other links can be relative. This is
// great, except some feed readers are buggy with it, INCLUDING FIREFOX!!!
// (See https://bugzilla.mozilla.org/show_bug.cgi?id=480600).
// BaseUri = new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex))
};
// self link (Required) - The URL for the syndication feed.
feed.Links.Add(SyndicationLink.CreateSelfLink(
new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetFeed)),
ContentType.Atom));
// alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed.
feed.Links.Add(SyndicationLink.CreateAlternateLink(
new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)),
ContentType.Html));
// hub link (Recommended) - The URL for the PubSubHubbub hub. Used to push new entries to subscribers
// instead of making them poll the feed. See feed updated method below.
feed.Links.Add(new SyndicationLink(new Uri(PubSubHubbubHubUrl), "hub", null, null, 0));
// first, last, next previous (Optional) - Atom 1.0 supports paging of your feed. This is good if your feed
// becomes very large and needs splitting up into pages. To add
// paging, you must add links to the first, last, next and previous
// feed pages.
// feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed"), "first", null, null, 0));
// feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=10"), "last", null, null, 0));
// if ([HAS_PREVIOUS_PAGE])
// feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=1")), "previous", null, null, 0));
// if ([HAS_NEXT_PAGE])
// feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=3"), "next", null, null, 0));
// author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed
// must contain at least one author element unless all of the entry elements contain
// at least one author element.
feed.Authors.Add(this.GetPerson());
// category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category
// elements.
feed.Categories.Add(new SyndicationCategory("CategoryName"));
// contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor
// elements.
feed.Contributors.Add(this.GetPerson());
// icon (Optional) - Identifies a small image which provides iconic visual identification for the feed.
// Icons should be square.
feed.SetIcon(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png"));
// Add the Yahoo Media namespace (xmlns:media="http://search.yahoo.com/mrss/") to the Atom feed.
// This gives us extra abilities, like the ability to give thumbnail images to entries.
// See http://www.rssboard.org/media-rss for more information.
feed.AddYahooMediaNamespace();
return feed;
}
示例2: GetFeed
/// <summary>
/// Gets the feed containing meta data about the feed and the feed entries.
/// </summary>
/// <returns>A <see cref="SyndicationFeed"/>.</returns>
public SyndicationFeed GetFeed()
{
SyndicationFeed feed = new SyndicationFeed()
{
// id (Required) - The feed universally unique identifier.
Id = FeedId,
// title (Required) - Contains a human readable title for the feed. Often the same as the title of the associated website. This value should not be blank.
Title = SyndicationContent.CreatePlaintextContent("ASP.NET MVC Boilerplate"),
// items (Required) - The items to add to the feed.
Items = this.GetItems(),
// subtitle (Recommended) - Contains a human-readable description or subtitle for the feed.
Description = SyndicationContent.CreatePlaintextContent("This is the ASP.NET MVC Boilerplate feed description."),
// updated (Optional) - Indicates the last time the feed was modified in a significant way.
LastUpdatedTime = DateTimeOffset.Now,
// logo (Optional) - Identifies a larger image which provides visual identification for the feed. Images should be twice as wide as they are tall.
ImageUrl = new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-logo-96x48.png")),
// rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the feed.
Copyright = new TextSyndicationContent(string.Format("© {0} - {0}", DateTime.Now.Year, Application.Name)),
// lang (Optional) - The language of the feed.
Language = "en-GB",
// generator (Optional) - Identifies the software used to generate the feed, for debugging and other purposes. Do not put in anything that identifies the technology you are using.
// Generator = "Sample Code",
// base (Buggy) - Add the full base URL to the site so that all other links can be relative. This is great, except some feed readers are buggy with it, INCLUDING FIREFOX!!! (See https://bugzilla.mozilla.org/show_bug.cgi?id=480600).
// BaseUri = new Uri(this.urlHelper.AbsoluteRouteUrl(ControllerRoute.HomeGetIndex))
};
// self link (Required) - The URL for the syndication feed.
feed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(this.urlHelper.AbsoluteRouteUrl(ControllerRoute.HomeGetFeed)), ContentType.Atom));
// alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed.
feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(this.urlHelper.AbsoluteRouteUrl(ControllerRoute.HomeGetIndex)), ContentType.Html));
// author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed must contain at least one author element unless all of the entry elements contain at least one author element.
feed.Authors.Add(this.GetPerson());
// category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category elements.
feed.Categories.Add(new SyndicationCategory("CategoryName"));
// contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor elements.
feed.Contributors.Add(this.GetPerson());
// icon (Optional) - Identifies a small image which provides iconic visual identification for the feed. Icons should be square.
feed.SetIcon(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png"));
// Add the Yahoo Media namespace (xmlns:media="http://search.yahoo.com/mrss/") to the Atom feed.
// This gives us extra abilities, like the ability to give thumbnail images to entries. See http://www.rssboard.org/media-rss for more information.
feed.AddYahooMediaNamespace();
return feed;
}