我有一个 SyndicationItem 对象的集合,我需要对其进行序列化,但我不确定如何去做。建议?
IEnumberable<SyndicationItem> blogPosts = GetBlogPosts();
...
private IEnumerable<SyndicationItem> GetBlogPosts()
{
var query = Enumerable.Empty<SyndicationItem>();
foreach (string feed in Feeds)
{
try
{
using (XmlReader reader = XmlReader.Create(feed))
{
query = query.Union((from item in SyndicationFeed.Load(reader).Items
orderby item.PublishDate descending
select item).Take(NumberOfItemsToDisplay));
}
}
catch (Exception ex)
{
Console.WriteLine("Invalid Feed: {0} ({1})", feed, ex.Message);
}
}
query = query.OrderByDescending(i => i.PublishDate).Take(NumberOfItemsToDisplay);
return query;
}