本文整理汇总了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;
}
示例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;
}
示例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");
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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
};
}
示例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");
}
示例12: AddPermalinkNull
public void AddPermalinkNull ()
{
SyndicationItem item = new SyndicationItem ();
item.AddPermalink (null);
}
示例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;
}