本文整理汇总了C#中System.ServiceModel.Syndication.SyndicationItem.GetAtom10Formatter方法的典型用法代码示例。如果您正苦于以下问题:C# SyndicationItem.GetAtom10Formatter方法的具体用法?C# SyndicationItem.GetAtom10Formatter怎么用?C# SyndicationItem.GetAtom10Formatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Syndication.SyndicationItem
的用法示例。
在下文中一共展示了SyndicationItem.GetAtom10Formatter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEntry
public SyndicationItem AddEntry(Uri feedUri, SyndicationItem newEntry)
{
if (feedUri == null)
{
throw new ArgumentNullException("feedUri");
}
if (newEntry == null)
{
throw new ArgumentNullException("newEntry");
}
return this.Post(feedUri, AtomEntryContentType, HttpContentExtensions.CreateDataContract(newEntry.GetAtom10Formatter())).EnsureStatusIs(HttpStatusCode.Created).Content.ReadAsDataContract<Atom10ItemFormatter>().Item;
}
示例2: GetEntry
public AtomEntry GetEntry(Id entryId)
{
ItemDataContext dc = new ItemDataContext();
Item item = dc.Items.Where(i => i.Id == entryId.ToString()).SingleOrDefault();
SyndicationItem si = new SyndicationItem()
{
Id = item.Id,
LastUpdatedTime = item.LastUpdatedTime,
PublishDate = item.PublishDate.Value
};
if (!string.IsNullOrEmpty(item.BaseUri)) si.BaseUri = new Uri(item.BaseUri);
LoadAttributes(si.AttributeExtensions, item.Attributes);
LoadElements(si.ElementExtensions, item.Elements);
LoadPersons(si.Authors, item.Persons, PersonTypeAuthor);
LoadPersons(si.Contributors, item.Persons, PersonTypeContributor);
si.Content = GetContent(item.Content);
si.Title = GetTextContent(item.Title);
si.Summary = GetTextContent(item.Summary);
si.Copyright = GetTextContent(item.Copyright);
LoadLinks(si.Links, item.Links);
LoadCategories(si.Categories, item.Categories);
using (Stream s = new MemoryStream())
{
XmlWriter w = new XmlTextWriter(s, Encoding.UTF8);
si.GetAtom10Formatter().WriteTo(w);
w.Flush();
AtomEntry entry = new AtomEntry();
s.Position = 0;
XmlReader r = new XmlTextReader(s);
entry.Xml = XElement.Load(r);
//entry.ReadXml(r);
return entry;
}
}
示例3: GetPost
public HttpResponseMessage GetPost(string id, HttpRequestMessage request)
{
var post = _postManager.Get(id);
if (post == null)
{
return new HttpResponseMessage()
{
StatusCode = HttpStatusCode.NotFound
};
}
if (request.AcceptsHtml())
{
return new HttpResponseMessage()
{
StatusCode = HttpStatusCode.OK,
Content = new ObjectContent(typeof(Post), post, new List<MediaTypeFormatter>() { new PostHtmlMediaTypeFormatter() })
};
}
else if (request.AcceptsAtom())
{
var item = new SyndicationItem()
{
Id = post.Id,
Title = new TextSyndicationContent(post.Title),
LastUpdatedTime = post.LastUpdatedTime,
Content = new TextSyndicationContent(post.Content)
};
return new HttpResponseMessage()
{
StatusCode = HttpStatusCode.OK,
Content = new ObjectContent(typeof(Atom10ItemFormatter), item.GetAtom10Formatter())
};
}
else
{
return new HttpResponseMessage()
{
StatusCode = HttpStatusCode.InternalServerError
};
}
}
示例4: UpdateEntry
public SyndicationItem UpdateEntry(Uri editUri, SyndicationItem newValue)
{
if (editUri == null)
{
throw new ArgumentNullException("editUri");
}
if (newValue == null)
{
throw new ArgumentNullException("newValue");
}
return this.Put(editUri, AtomEntryContentType, HttpContentExtensions.CreateDataContract(newValue.GetAtom10Formatter())).EnsureStatusIs(HttpStatusCode.OK).Content.ReadAsDataContract<Atom10ItemFormatter>().Item;
}