当前位置: 首页>>代码示例>>C#>>正文


C# SyndicationItem.SetThumbnail方法代码示例

本文整理汇总了C#中System.ServiceModel.Syndication.SyndicationItem.SetThumbnail方法的典型用法代码示例。如果您正苦于以下问题:C# SyndicationItem.SetThumbnail方法的具体用法?C# SyndicationItem.SetThumbnail怎么用?C# SyndicationItem.SetThumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Syndication.SyndicationItem的用法示例。


在下文中一共展示了SyndicationItem.SetThumbnail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetItems

        /// <summary>
        /// Gets the collection of <see cref="SyndicationItem"/>'s that represent the atom entries.
        /// </summary>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> signifying if the request is cancelled.</param>
        /// <returns>A collection of <see cref="SyndicationItem"/>'s.</returns>
        private async Task<List<SyndicationItem>> GetItems(CancellationToken cancellationToken)
        {
            List<SyndicationItem> items = new List<SyndicationItem>();

            for (int i = 1; i < 4; ++i)
            {
                SyndicationItem item = new SyndicationItem()
                {
                    // id (Required) - Identifies the entry using a universally unique and permanent URI. Two entries 
                    //                 in a feed can have the same value for id if they represent the same entry at 
                    //                 different points in time.
                    Id = FeedId + i,
                    // title (Required) - Contains a human readable title for the entry. This value should not be blank.
                    Title = SyndicationContent.CreatePlaintextContent("Item " + i),
                    // description (Recommended) - A summary of the entry.
                    Summary = SyndicationContent.CreatePlaintextContent("A summary of item " + i),
                    // updated (Optional) - Indicates the last time the entry was modified in a significant way. This 
                    //                      value need not change after a typo is fixed, only after a substantial 
                    //                      modification. Generally, different entries in a feed will have different 
                    //                      updated timestamps.
                    LastUpdatedTime = DateTimeOffset.Now,
                    // published (Optional) - Contains the time of the initial creation or first availability of the entry.
                    PublishDate = DateTimeOffset.Now,
                    // rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the entry.
                    Copyright = new TextSyndicationContent(
                        string.Format("© {0} - {1}", DateTime.Now.Year, Application.Name)),
                };

                // link (Recommended) - Identifies a related Web page. An entry must contain an alternate link if there 
                //                      is no content element.
                item.Links.Add(SyndicationLink.CreateAlternateLink(
                    new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)), 
                    ContentType.Html));
                // AND/OR
                // Text content  (Optional) - Contains or links to the complete content of the entry. Content must be 
                //                            provided if there is no alternate link.
                // item.Content = SyndicationContent.CreatePlaintextContent("The actual plain text content of the entry");
                // HTML content (Optional) - Content can be plain text or HTML. Here is a HTML example.
                // item.Content = SyndicationContent.CreateHtmlContent("The actual HTML content of the entry");

                // author (Optional) - Names one author of the entry. An entry may have multiple authors. An entry must 
                //                     contain at least one author element unless there is an author element in the 
                //                     enclosing feed, or there is an author element in the enclosed source element.
                item.Authors.Add(this.GetPerson());

                // contributor (Optional) - Names one contributor to the entry. An entry may have multiple contributor elements.
                item.Contributors.Add(this.GetPerson());

                // category (Optional) - Specifies a category that the entry belongs to. A entry may have multiple 
                //                       category elements.
                item.Categories.Add(new SyndicationCategory("CategoryName"));

                // link - Add additional links to related images, audio or video like so.
                item.Links.Add(SyndicationLink.CreateMediaEnclosureLink(
                    new Uri(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png")), 
                    ContentType.Png, 
                    0));

                // media:thumbnail - Add a Yahoo Media thumbnail for the entry. See http://www.rssboard.org/media-rss 
                //                   for more information.
                item.SetThumbnail(this.urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png"), 48, 48);

                items.Add(item);
            }

            return items;
        }
开发者ID:spawnpoint,项目名称:FantasyPLGraphs,代码行数:72,代码来源:FeedService.cs


注:本文中的System.ServiceModel.Syndication.SyndicationItem.SetThumbnail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。