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


C# SyndicationItem.AddPermalink方法代码示例

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


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

示例1: CreateSyndicationItem

        private SyndicationItem CreateSyndicationItem(IContent content)
        {
            var changeTrackable = content as IChangeTrackable;
            var changed = DateTime.Now;
            var changedby = string.Empty;

            if (changeTrackable != null)
            {
                changed = changeTrackable.Saved;
                changedby = changeTrackable.ChangedBy;
            }

            var item = new SyndicationItem
            {
                Title = new TextSyndicationContent(content.Name),
                Summary = new TextSyndicationContent(FeedDescriptionProvider.ItemDescripton(content)),
                PublishDate = changed,
            };

            foreach (var contentCategory in ContentCategoryLoader.GetContentCategories(content))
            {
                item.Categories.Add(new SyndicationCategory(contentCategory));
            }         

            var mimeType = GetMimeType(content);
            Uri url = GetItemUrl(content);

            item.Content = new UrlSyndicationContent(url, mimeType);
            item.AddPermalink(url);
            item.Authors.Add(new SyndicationPerson(string.Empty, changedby, string.Empty));

            return item;
        }
开发者ID:pappabj0rn,项目名称:Chief2moro.SyndicationFeeds,代码行数:33,代码来源:SyndicationItemFactory.cs

示例2: CreateSyndicationItem

        private SyndicationItem CreateSyndicationItem(IContent content)
        {
            var changeTrackable = content as IChangeTrackable;
            var changed = DateTime.Now;
            var changedby = string.Empty;

            if (changeTrackable != null)
            {
                changed = changeTrackable.Saved;
                changedby = changeTrackable.ChangedBy;
            }
            
            var item = new SyndicationItem
            {
                Id = content.ContentLink.ID.ToString(),
                Title = new TextSyndicationContent(content.Name),
                Summary = new TextSyndicationContent(FeedInformationHandler.SetItemDescription(content)),
                PublishDate = changed,
                LastUpdatedTime = changed,
            };
            
            var mimeType = GetMimeType(content);
            Uri url = GetItemUrl(content);

            item.Content = new UrlSyndicationContent(url, mimeType);
            item.AddPermalink(url);
            item.Authors.Add(new SyndicationPerson(string.Empty, changedby, string.Empty));

            return item;
        }
开发者ID:jumpingcode,项目名称:Chief2moro.SyndicationFeeds,代码行数:30,代码来源:SyndicationItemFactory.cs

示例3: AddPermalink

		public void AddPermalink ()
		{
			SyndicationItem item = new SyndicationItem ();
			Assert.AreEqual (0, item.Links.Count, "#1");
			item.AddPermalink (new Uri ("http://mono-project.com/index.rss.20071210"));
			Assert.AreEqual (1, item.Links.Count, "#2");
			SyndicationLink link = item.Links [0];
			Assert.AreEqual ("http://mono-project.com/index.rss.20071210", link.Uri.ToString (), "#3");
			Assert.AreEqual ("alternate", link.RelationshipType, "#4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:SyndicationItemTest.cs

示例4: AtomFeedResult

        /// <summary>
        /// FileResultのコンストラクタをオーバーライド
        /// </summary>
        /// <param name="feedItems">RSSで配信したいアイテム</param>
        public AtomFeedResult(Uri blogBaseUrl, string blogTitle, string blogDescription, List<Article> articles)
            : base("application/atom+xml")
        {
            if (blogBaseUrl == null)
            {
                throw new ArgumentNullException("blogUrl");
            }

            if (string.IsNullOrEmpty(blogTitle) || string.IsNullOrWhiteSpace(blogTitle))
            {
                blogTitle = string.Empty;
            }

            if (string.IsNullOrEmpty(blogDescription) || string.IsNullOrWhiteSpace(blogDescription))
            {
                blogTitle = string.Empty;
            }

            List<SyndicationItem> syndicationItems = new List<SyndicationItem>();
            foreach (Article article in articles)
            {
                SyndicationItem item = new SyndicationItem();

                // 記事のパーマネントリンク生成処理
                Uri articleUrl = null;
                if (Uri.TryCreate(blogBaseUrl, string.Format("/article/{0}", article.Id), out articleUrl))
                {
                    item.AddPermalink(articleUrl);
                }
                else
                {
                    // URIが生成できない場合は一意性を保てないためスキップする
                    continue;
                }

                item.Title = new TextSyndicationContent(article.Title);
                item.Content = SyndicationContent.CreatePlaintextContent(article.Body);
                item.PublishDate = article.OpenDate;
                item.LastUpdatedTime = article.UpdateDate;
                // item.Categories.Add(new SyndicationCategory("category name"));

                syndicationItems.Add(item);
            }

            _feed = new SyndicationFeed(blogTitle, blogDescription, HttpContext.Current.Request.Url, syndicationItems);
            _feed.Language = "ja-JP";
            _feed.Generator = AppSettings.GetBlogSystemName();
        }
开发者ID:hiroakit,项目名称:blog,代码行数:52,代码来源:AtomFeedResult.cs

示例5: CreateSyndicationItem

        //create factory
        public SyndicationItem CreateSyndicationItem(FeedEntryViewModel item)
        {
            Uri link = item.GetLinkUri();
            string description = item.Description;
            string title = item.Title;
            var url = _httpRequestBase.Url;
            var permalink = CreatePermalink(item, url);

            description += CreateDescriptionFromPermanlink(item, permalink);

            var syndicationItem = new SyndicationItem(title, description, link);
            syndicationItem.PublishDate = item.PublishedAt;
            syndicationItem.AddPermalink(permalink);

            return syndicationItem;
        }
开发者ID:CasperTDK,项目名称:RSSFeed,代码行数:17,代码来源:SyndicationFeedFactory.cs

示例6: ConvertItem

        private SyndicationItem ConvertItem( BlogPostDocument document )
        {
            var result = new SyndicationItem(document.Title, MarkdownHelper.RenderMarkdown(document.Content),
                                             Url.AbsoluteAction("Details", "BlogPost", new {id = document.GetUrlId()}),
                                             document.GetUrlId().ToString(CultureInfo.InvariantCulture),
                                             document.UpdatedOn);

            result.AddPermalink(Url.AbsoluteAction("Details","BlogPost",new {id = document.Title}));

            foreach (var link in (document.Links ?? new Link[0]).Where(l => !string.IsNullOrWhiteSpace(l.Url)))
            {
                result.Links.Add(new SyndicationLink(new Uri(link.Url),"external",link.Title,"text/html",0));
            }

            return result;
        }
开发者ID:BernhardGlueck,项目名称:DevPost,代码行数:16,代码来源:FeedController.cs

示例7: GetRecentPagesOrPosts

        private List<SyndicationItem> GetRecentPagesOrPosts(RSSFeedInclude feedData)
        {
            List<SyndicationItem> syndRSS = new List<SyndicationItem>();
            List<SiteNav> lst = new List<SiteNav>();

            ContentPageType PageType = new ContentPageType();

            using (SiteNavHelper navHelper = new SiteNavHelper()) {
                if (feedData == RSSFeedInclude.PageOnly || feedData == RSSFeedInclude.BlogAndPages) {
                    List<SiteNav> lst1 = navHelper.GetLatest(this.SiteID, 8, true);
                    lst = lst.Union(lst1).ToList();
                    List<SiteNav> lst2 = navHelper.GetLatestUpdates(this.SiteID, 10, true);
                    lst = lst.Union(lst2).ToList();
                }
                if (feedData == RSSFeedInclude.BlogOnly || feedData == RSSFeedInclude.BlogAndPages) {
                    List<SiteNav> lst1 = navHelper.GetLatestPosts(this.SiteID, 8, true);
                    lst = lst.Union(lst1).ToList();
                    List<SiteNav> lst2 = navHelper.GetLatestPostUpdates(this.SiteID, 10, true);
                    lst = lst.Union(lst2).ToList();
                }
            }

            lst.RemoveAll(x => x.ShowInSiteMap == false && x.ContentType == ContentPageType.PageType.ContentEntry);
            lst.RemoveAll(x => x.BlockIndex == true);

            foreach (SiteNav sn in lst) {
                SyndicationItem si = new SyndicationItem();

                string sPageURI = RemoveDupeSlashesURL(this.ConstructedCanonicalURL(sn));

                Uri PageURI = new Uri(sPageURI);

                si.Content = new TextSyndicationContent(sn.PageTextPlainSummaryMedium);
                si.Title = new TextSyndicationContent(sn.NavMenuText);
                si.Links.Add(SyndicationLink.CreateSelfLink(PageURI));
                si.AddPermalink(PageURI);

                si.LastUpdatedTime = sn.EditDate;
                si.PublishDate = sn.CreateDate;

                syndRSS.Add(si);
            }

            return syndRSS.OrderByDescending(p => p.PublishDate).ToList();
        }
开发者ID:mjohn,项目名称:CarrotCakeCMS,代码行数:45,代码来源:SiteData.cs

示例8: TransformPost

 private SyndicationItem TransformPost(PostEntry entry)
 {
     entry = RenderEntry(entry);
     SyndicationItem item = new SyndicationItem();
     item.Id = entry.Name;
     item.Title = SyndicationContent.CreatePlaintextContent(entry.Title);
     item.Content = SyndicationContent.CreateHtmlContent(Transformer.Transform(entry.Content));
     item.AddPermalink(new Uri("http://otakustay.com/" + entry.Name + "/"));
     item.PublishDate = new DateTimeOffset(entry.PostDate);
     item.LastUpdatedTime = new DateTimeOffset(entry.UpdateDate);
     item.Authors.Add(Author.Clone());
     return item;
 }
开发者ID:otakustay,项目名称:Alice,代码行数:13,代码来源:PostController.cs

示例9: Rss

        //[OutputCache(Duration = 43200)]
        public ActionResult Rss(int? id)
        {
            string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                var posts = from p in db.BlogPosts select p;
                string feedTitle = WebConfigurationManager.AppSettings["PageTitle"];
                List<SyndicationItem> feedItems = new List<SyndicationItem>();
                if (id != null)
                {
                    posts = posts.Where(post => post.CategoryId == id);
                    Category category = db.Categories.Find(id);
                    feedTitle += "-" + category.Name;
                }

                foreach (BlogPost p in posts.Where(x=>x.IsPublished).OrderBy(p => p.PublishDate).Take(int.Parse(WebConfigurationManager.AppSettings["MaxRssPosts"])).ToList())
                {
                    string picture = "";
                    picture = p.Picture + "?w=900&h=300&mode=crop";
                    if (p.Picture == WebConfigurationManager.AppSettings["NoPostPictureName"])
                    {
                        picture = p.Picture;
                    }
                    var Summary = "<div dir=\"rtl\" style=\"font-family:tahoma\"><img src=\"" + baseUrl + "Uploads/images_post/" + picture + "\" /><br/>" + p.Preview + "</div>";
                    if (p.ShowPicture == false)
                    {
                        Summary = "<div dir=\"rtl\" style=\"font-family:tahoma\">" + p.Preview + "</div>";
                    }

                    var item = new SyndicationItem();
                    item.AddPermalink(new Uri(new Uri (baseUrl), "BlogPosts/Details/" + p.CategoryId + "/" + p.GenerateSlug(),true));
                    item.Id = p.Id.ToString();
                    item.Title = new TextSyndicationContent(p.Title, TextSyndicationContentKind.Html);
                    item.Summary = new CDataSyndicationContent(new TextSyndicationContent(Summary, TextSyndicationContentKind.Html));
                    item.Categories.Add(new SyndicationCategory(p.Category.Name));
                    item.Authors.Add(new SyndicationPerson(p.Author.Email, p.Author.FirstName + " " + p.Author.LastName, ""));
                    item.Copyright = new TextSyndicationContent(WebConfigurationManager.AppSettings["Copyright"], TextSyndicationContentKind.Html);
                    item.PublishDate = p.PublishDate;
                    item.LastUpdatedTime = p.LastModifiedDate;
                    var content = "<div dir=\"rtl\" style=\"font-family:tahoma\"><img src=\"" + baseUrl + "Uploads/images_post/" + picture + "\" /><br/>" + p.Content + "</div>";
                    if (p.ShowPicture == false)
                    {
                        content = "<div dir=\"rtl\" style=\"font-family:tahoma\">" + p.Content + "</div>";
                    }
                    item.Content = new CDataSyndicationContent(new TextSyndicationContent(content, TextSyndicationContentKind.Html));
                    feedItems.Add(item);
                }
                SyndicationFeed feed = new SyndicationFeed(feedItems)
                {
                    Id = "0",
                    Title = new TextSyndicationContent(feedTitle, TextSyndicationContentKind.Plaintext),
                    ImageUrl = new Uri(new Uri(baseUrl), "favicon-32x32.png")

                };

                //foreach (Category category in db.Categories.ToList()) {
                //    feed.Categories.Add(new SyndicationCategory(category.Name));
                //}
                return new RssActionResult(feed);
            }
        }
开发者ID:saeedesmaeili,项目名称:SimpleBlog,代码行数:63,代码来源:CategoriesController.cs

示例10: Index

        public ActionResult Index(string status, string assignedTo)
        {
            var filterText = "";
            if (status.HasValue())
                filterText += "status '" + status + "'";
            if (assignedTo.HasValue())
            {
                if (filterText.HasValue())
                    filterText += " and ";
                filterText += "assigned to '" + assignedTo + "'";
            }
            if (filterText.HasValue())
                filterText = " (filtered by " + filterText + ")";

            var feed = new SyndicationFeed
            {
                BaseUri = new Uri("http://issuetracker.epunkt.net"),
                Generator = "IssueTracker",
                LastUpdatedTime = DateTime.Now.ToUniversalTime(),
                Title = new TextSyndicationContent("Issues" + filterText)
            };

            var context = new Db();
            var issues = from x in context.Issues
                         where !x.ParentIssueId.HasValue
                         select x;

            if (status.HasValue())
                issues = issues.Where(x => x.Status == status);

            if (assignedTo.HasValue())
                issues = assignedTo.Is("-") ? issues.Where(x => x.AssignedTo == null) : issues.Where(x => x.AssignedTo == assignedTo);

            var url = Request.Url;
            if (url == null)
                throw new ApplicationException("No 'Request.Url' available.");
            var baseUrl = url.ToString();
            baseUrl = baseUrl.Substring(0, baseUrl.ToLower().IndexOf("/rss", StringComparison.InvariantCultureIgnoreCase));

            var items = new List<SyndicationItem>();
            foreach (var issue in issues)
            {
                var item = new SyndicationItem
                {
                    Title = SyndicationContent.CreatePlaintextContent(issue.Text),
                    Content =
                        SyndicationContent.CreateHtmlContent("<pre>" + issue.StackTrace.Replace("\r", "").Replace("\n", "<br />") + "</pre><hr /><pre>" +
                                                             issue.ServerVariables.Replace("\r", "").Replace("\n", "<br />") + "</pre>"),
                    Id = issue.Id.ToString(CultureInfo.CurrentCulture)
                };
                item.AddPermalink(new Uri(baseUrl + "/Issue/Details/" + issue.Id));
                item.LastUpdatedTime = issue.DateOfUpdate;
                item.PublishDate = issue.DateOfCreation;
                item.Authors.Add(new SyndicationPerson(issue.Creator));

                items.Add(item);
            }
            feed.Items = items;

            return new RssActionResult
            {
                Feed = feed
            };
        }
开发者ID:saxx,项目名称:IssueTracker,代码行数:64,代码来源:RssController.cs

示例11: Clone

		public void Clone ()
		{
			SyndicationItem item = new SyndicationItem ();
			item.AddPermalink (new Uri ("http://mono-project.com/index.rss.20071210"));
			item.Id = Guid.NewGuid ().ToString ();
			item.BaseUri = new Uri ("http://mono-project.com");
			item.Authors.Add (new SyndicationPerson ("[email protected]"));
			item.SourceFeed = new SyndicationFeed ();
			item.SourceFeed.Items = new SyndicationItem [] {new SyndicationItem ()};

			SyndicationItem clone = item.Clone ();
			Assert.AreEqual (1, clone.Links.Count, "#1");
			Assert.AreEqual (item.Id, clone.Id, "#2"); // hmm ...
			Assert.AreEqual ("http://mono-project.com/", clone.BaseUri.ToString (), "#3");

			// LAMESPEC: .NET fails to clone it
			// Assert.IsFalse (Object.ReferenceEquals (item.BaseUri, clone.BaseUri), "#4"); // should not be just a shallow copy

			Assert.IsNull (clone.Title, "#5");
			Assert.IsNotNull (clone.SourceFeed, "#6");
			Assert.IsFalse (Object.ReferenceEquals (item.SourceFeed, clone.SourceFeed), "#7"); // ... not just a shallow copy??
			// items in the SourceFeed are not cloned, but Items property is not null
			Assert.IsNotNull (clone.SourceFeed.Items, "#8-1");
			Assert.IsFalse (clone.SourceFeed.Items.GetEnumerator ().MoveNext (), "#8-2");
			Assert.AreEqual (1, clone.Authors.Count, "#9");
			SyndicationPerson person = clone.Authors [0];
			Assert.IsFalse (Object.ReferenceEquals (item.Authors [0], person), "#10"); // should not be just a shallow copy
			Assert.AreEqual ("[email protected]", person.Email, "#11");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:SyndicationItemTest.cs

示例12: AddPermalinkNull

		public void AddPermalinkNull ()
		{
			SyndicationItem item = new SyndicationItem ();
			item.AddPermalink (null);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:SyndicationItemTest.cs

示例13: BuildSyndicationItem

        private SyndicationItem BuildSyndicationItem(AnnouncementInfo ann)
        {
            var item = new SyndicationItem();
            if (ann.PublishDate != null)
                item.PublishDate = DateTime.SpecifyKind(ann.PublishDate.Value,DateTimeKind.Utc);

            item.Content = new TextSyndicationContent(ann.Description, TextSyndicationContentKind.Html);
            item.LastUpdatedTime = DateTime.SpecifyKind(ann.LastModifiedOnDate, DateTimeKind.Utc);
            item.Title = new TextSyndicationContent(ann.Title);
            var p = ann.Permalink;
            if (p != null)
            {
                //item.BaseUri = new Uri(p);
                item.AddPermalink(new Uri(p));
            }

            if (ann.URL != "")
            {
                item.Links.Add(new SyndicationLink(new Uri(ann.URL)));
                item.Id = ann.URL;
            }

            item.Authors.Add(new SyndicationPerson { Name = ann.LastModifiedByUserID.ToString(CultureInfo.InvariantCulture) });
            return item;
        }
开发者ID:schotman,项目名称:DNN.Announcements,代码行数:25,代码来源:SyndicationFeedFormatter.cs


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