本文整理汇总了C#中System.ServiceModel.Syndication.SyndicationLink类的典型用法代码示例。如果您正苦于以下问题:C# SyndicationLink类的具体用法?C# SyndicationLink怎么用?C# SyndicationLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyndicationLink类属于System.ServiceModel.Syndication命名空间,在下文中一共展示了SyndicationLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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());
}
示例2: GetPostFeed
public static SyndicationFeed GetPostFeed()
{
SyndicationFeed postfeed = Feeds.GetFeed();
postfeed.Title = new TextSyndicationContent("Key Mapper Developer Blog");
postfeed.Description = new TextSyndicationContent("Post feed for the Key Mapper Developer Blog");
Collection<Post> posts = Post.GetAllPosts(CommentType.Approved);
List<SyndicationItem> items = new List<SyndicationItem>();
foreach (Post p in posts)
{
SyndicationItem item = new SyndicationItem();
item.Id = p.Id.ToString();
item.Title = new TextSyndicationContent(p.Title);
item.Content = new TextSyndicationContent(p.Body);
SyndicationLink itemlink = new SyndicationLink();
itemlink.Title = "Key Mapper Blog";
itemlink.Uri = new Uri("http://justkeepswimming.net/keymapper/default.aspx?p="
+ p.Id.ToString() + ".aspx");
item.Links.Add(itemlink);
SyndicationPerson person = new SyndicationPerson();
person.Name = "Stuart Dunkeld";
person.Email = "[email protected]";
item.Authors.Add(person);
items.Add(item);
}
postfeed.Items = items;
return postfeed;
}
示例3: 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
};
}
示例4: GetBlogInformation
private static SyndicationFeed GetBlogInformation(string pbaseUrl) {
var feed = new SyndicationFeed();
// Add basic blog information
feed.Id = pbaseUrl;
feed.Title = new TextSyndicationContent("Kestrel Blackmore Blog");
feed.Description = new TextSyndicationContent("Hi, I'm Kestrel. I've been a software developer now for 10+ years and I love it!");
feed.Copyright = new TextSyndicationContent("KestrelBlackmore.com");
feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now);
feed.Generator = "BlogMatrix 1.0";
feed.ImageUrl = new Uri(pbaseUrl + "/assets/img/blackmore_logo.png");
// Add the URL that will link to your published feed when it's done
SyndicationLink link = new SyndicationLink(new Uri(pbaseUrl + "/feed.xml"));
link.RelationshipType = "self";
link.MediaType = "text/html";
link.Title = "Kestrel Blackmore Feed";
feed.Links.Add(link);
// Add your site link
link = new SyndicationLink(new Uri(pbaseUrl));
link.MediaType = "text/html";
link.Title = "Kestrel Blackmore Blog";
feed.Links.Add(link);
return feed;
}
示例5: TestUri
public void TestUri ()
{
SyndicationLink link = new SyndicationLink (new Uri ("empty.xml", UriKind.Relative));
link.Uri = null;
Assert.IsNull (link.Uri, "#1");
Assert.IsNull (link.GetAbsoluteUri (), "#2");
}
示例6: GetXmlContents
private Action<Stream> GetXmlContents(IEnumerable<Post> model)
{
var items = new List<SyndicationItem>();
foreach (var post in model)
{
// Replace all relative urls with full urls.
var contentHtml = Regex.Replace(post.Content, UrlRegex, m => siteUrl.TrimEnd('/') + "/" + m.Value.TrimStart('/'));
var excerptHtml = Regex.Replace(post.ContentExcerpt, UrlRegex, m => siteUrl.TrimEnd('/') + "/" + m.Value.TrimStart('/'));
var item = new SyndicationItem(
post.Title,
contentHtml,
new Uri(siteUrl + post.Url)
)
{
Id = siteUrl + post.Url,
LastUpdatedTime = post.Date.ToUniversalTime(),
PublishDate = post.Date.ToUniversalTime(),
Content = new TextSyndicationContent(contentHtml, TextSyndicationContentKind.Html),
Summary = new TextSyndicationContent(excerptHtml, TextSyndicationContentKind.Html),
};
items.Add(item);
}
var feed = new SyndicationFeed(
AtomTitle,
AtomTitle, /* Using Title also as Description */
new Uri(siteUrl + "/" + feedfileName),
items)
{
Id = siteUrl + "/",
LastUpdatedTime = new DateTimeOffset(DateTime.Now),
Generator = "Sandra.Snow Atom Generator"
};
feed.Authors.Add(new SyndicationPerson(authorEmail, author, siteUrl));
var link = new SyndicationLink(new Uri(siteUrl + "/" + feedfileName))
{
RelationshipType = "self",
MediaType = "text/html",
Title = AtomTitle
};
feed.Links.Add(link);
var formatter = new Atom10FeedFormatter(feed);
return stream =>
{
var encoding = new UTF8Encoding(false);
var streamWrapper = new UnclosableStreamWrapper(stream);
using (var writer = new XmlTextWriter(streamWrapper, encoding))
{
formatter.WriteTo(writer);
}
};
}
示例7: GetBlogInformation
private static SyndicationFeed GetBlogInformation(string pbaseUrl) {
var feed = new SyndicationFeed();
// Add basic blog information
feed.Id = pbaseUrl;
feed.Title = new TextSyndicationContent("제이키의 ASP.NET MVC 이야기");
feed.Description = new TextSyndicationContent("ASP.NET MVC를 공부하면서 테스트 가능한 웹 애플리케이션을 만들어 봅시다. 테스트를 염두에 두면 유연한 아키텍쳐가 필요하고 좋은 아키텍쳐는 코드 재사용성을 높이고 유지보수를 쉽게 해줍니다.");
feed.Copyright = new TextSyndicationContent("류지형 (Jake Ryu)");
feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now);
feed.Generator = "JakeyMVC.com";
feed.ImageUrl = new Uri(pbaseUrl + "/assets/img/logo_white.gif");
// Add the URL that will link to your published feed when it's done
SyndicationLink link = new SyndicationLink(new Uri(pbaseUrl + "/feed"));
link.RelationshipType = "self";
link.MediaType = "text/html";
link.Title = "Jakey MVC Feed";
feed.Links.Add(link);
// Add your site link
link = new SyndicationLink(new Uri(pbaseUrl));
link.MediaType = "text/html";
link.Title = "JakeyMVC.com";
feed.Links.Add(link);
return feed;
}
示例8: CreateFeed
public SyndicationFeedFormatter CreateFeed()
{
string serverUrl = ConfigurationManager.AppSettings["CatMyVideoUrl"];
// Create a new Syndication Feed.
SyndicationFeed feed = new SyndicationFeed();
feed.Id = "#CatMyVideo URL";
List<SyndicationItem> items = new List<SyndicationItem>();
feed.Title = new TextSyndicationContent("Last trends on CatMyVideo");
feed.Description = new TextSyndicationContent(String.Format("Todays' top {0} hottest videos on CatMyVideo", MAXVIDEO));
feed.Copyright = new TextSyndicationContent("Copy/Paste rights CatMyVideo");
feed.Generator = "CatMyVideo RSS Feeder 1.0";
feed.Authors.Add(new SyndicationPerson("[email protected]"));
feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now);
var trendingVideos = Engine.BusinessManagement.Video.ListVideos(Engine.Dbo.Video.Order.UploadDate, false, MAXVIDEO, 0, true);
for (int i = 0; i < trendingVideos.Count; i++)
{
SyndicationItem item = new SyndicationItem();
string itemUrl = serverUrl + "/Video/Display/" + trendingVideos[i].Id;
item.Id = itemUrl;
var itemLink = new SyndicationLink(new Uri(itemUrl));
itemLink.MediaType = "text/html";
itemLink.Title = "Watch me !";
item.Links.Add(itemLink);
string htmlContent = String.Format("<!DOCTYPE html><html><head></head><body><h1>{0}</h1><p>{1}</p><a href=\"{2}\">Check this out !</a></body></html>",
trendingVideos[i].Title,
trendingVideos[i].Description,
itemUrl);
TextSyndicationContent content = new TextSyndicationContent(htmlContent, TextSyndicationContentKind.Html);
// Fill some properties for the item
item.Title = new TextSyndicationContent("#" + (i + 1));
item.LastUpdatedTime = DateTime.Now;
item.PublishDate = trendingVideos[i].UploadDate;
item.Content = content;
items.Add(item);
}
feed.Items = items;
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: fload
public void fload(string namefile)
{
var lines = System.IO.File.ReadAllLines(namefile);
feed.Title = new TextSyndicationContent(lines[1]);
feed.Copyright = new TextSyndicationContent(lines[2]);
feed.Description = new TextSyndicationContent(lines[3]);
feed.Generator = lines[4];
SyndicationLink link = new SyndicationLink();
link.Uri = new Uri(lines[5]);
feed.Links.Add(link);
feed.Items = txtgotolv("feedinfo.txt");
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
XmlWriter Writer = XmlWriter.Create
(Response.Output);
if (lines[0] == "rss")
{
Rss20FeedFormatter Formatter = new Rss20FeedFormatter(feed);
Formatter.WriteTo(Writer);
}
else
{
if (lines[0] == "atom")
{
Atom10FeedFormatter Formatter = new Atom10FeedFormatter(feed);
Formatter.WriteTo(Writer);
}
}
Writer.Close();
Response.End();
}
示例10: ToSyndicationLink
public static SyndicationLink ToSyndicationLink(this Link link)
{
var syndicationLink = new SyndicationLink(new Uri(link.Url));
link.Rel.IfNotNull(x => syndicationLink.RelationshipType = x);
link.Title.IfNotNull(x => syndicationLink.Title = x);
link.ContentType.IfNotNull(x => syndicationLink.MediaType = x);
return syndicationLink;
}
示例11: SyndicationLink
protected SyndicationLink(SyndicationLink source)
{
if (source == null)
throw new ArgumentNullException ("source");
base_uri = source.base_uri;
href = source.href;
length = source.length;
rel = source.rel;
title = source.title;
type = source.type;
extensions = source.extensions.Clone ();
}
示例12: JsonSyndicationLink
public JsonSyndicationLink(SyndicationLink link)
{
if (link != null)
{
this.Length = link.Length;
this.MediaType = link.MediaType;
this.RelationshipType = link.RelationshipType;
this.Title = link.Title;
this.Uri = link.BaseUri;
this.Uri = link.Uri;
}
}
示例13: Constructor
public void Constructor ()
{
// null Uri is allowed
SyndicationLink link = new SyndicationLink (null);
link = new SyndicationLink (new Uri ("empty.xml", UriKind.Relative));
Assert.AreEqual ("empty.xml", link.Uri.ToString (), "#1-1");
Assert.AreEqual (null, link.BaseUri, "#1-2");
Assert.AreEqual (0, link.Length, "#1-3");
Assert.AreEqual (null, link.MediaType, "#1-4");
link = new SyndicationLink (null, null, null, null, 0);
}
示例14: AddMoreResultsLink
public FeedBuilder AddMoreResultsLink(Uri baseUri, string key, int? page)
{
var moreresultsuri = string.Format("{0}?key={1}&page={2}", "search", key, page);
//TODO: Fix this uri
this.moreResultsLink = new SyndicationLink(new Uri(baseUri, moreresultsuri))
{
RelationshipType = "next-results"
};
return this;
}
示例15: GetFeed
public static SyndicationFeed GetFeed()
{
SyndicationFeed feed = new SyndicationFeed();
feed.Copyright = new TextSyndicationContent("Copyright (C) Stuart Dunkeld 2008. All rights reserved.");
feed.Generator = "ASP.Net 3.5 Syndication classes";
SyndicationLink link = new SyndicationLink();
link.Title = "Key Mapper Home";
link.Uri = new Uri("http://justkeepswimming.net/keymapper");
feed.Links.Add(link);
return feed;
}