Atom10FeedFormatter<TSyndicationFeed> 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
一个用于在 SyndicationFeed 派生类与 Atom 1.0 格式之间来回序列化的类。
generic <typename TSyndicationFeed>
where TSyndicationFeed : SyndicationFeedgcnew()public ref class Atom10FeedFormatter : System::ServiceModel::Syndication::Atom10FeedFormatter
public class Atom10FeedFormatter<TSyndicationFeed> : System.ServiceModel.Syndication.Atom10FeedFormatter where TSyndicationFeed : SyndicationFeed, new()
type Atom10FeedFormatter<'SyndicationFeed (requires 'SyndicationFeed :> SyndicationFeed and 'SyndicationFeed : (new : unit -> 'SyndicationFeed))> = class
inherit Atom10FeedFormatter
Public Class Atom10FeedFormatter(Of TSyndicationFeed)
Inherits Atom10FeedFormatter
类型参数
- TSyndicationFeed
要序列化的 SyndicationFeed 派生类型。
- 继承
示例
下面的代码演示如何创建 SyndicationFeed 派生类并将其序列化为 Atom 1.0。
MySyndicationFeed feed = new MySyndicationFeed("Test Feed", "This is a test feed", new Uri("http://Contoso/testfeed"), "TestFeedID", DateTime.Now);
SyndicationItem item = new SyndicationItem("Test Item", "This is the content for Test Item", new Uri("http://localhost/ItemOne"), "TestItemID", DateTime.Now);
item.Links.Add(new SyndicationLink(new Uri("http://someuri"), "alternate", "MyItemLink", "text/html", 100));
item.PublishDate = new DateTime(1968, 2, 23);
item.LastUpdatedTime = DateTime.Today;
item.SourceFeed = feed;
item.Summary = new TextSyndicationContent("This the item summary");
List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
feed.Items = items;
XmlWriter atomWriter = XmlWriter.Create("Atom.xml");
Atom10FeedFormatter<MySyndicationFeed> atomFormatter = new Atom10FeedFormatter<MySyndicationFeed>(feed);
atomFormatter.WriteTo(atomWriter);
atomWriter.Close();
Dim feed As MySyndicationFeed = New MySyndicationFeed("Test Feed", "This is a test feed", New Uri("http:'Contoso/testfeed"), "TestFeedID", DateTime.Now)
Dim item As SyndicationItem = New SyndicationItem("Test Item", "This is the content for Test Item", New Uri("http:'localhost/ItemOne"), "TestItemID", DateTime.Now)
item.Links.Add(New SyndicationLink(New Uri("http:'someuri"), "alternate", "MyItemLink", "text/html", 100))
item.PublishDate = New DateTime(1968, 2, 23)
item.LastUpdatedTime = DateTime.Today
item.SourceFeed = feed
item.Summary = New TextSyndicationContent("This the item summary")
Dim items As List(Of SyndicationItem) = New List(Of SyndicationItem)
items.Add(item)
feed.Items = items
Dim atomWriter As XmlWriter = XmlWriter.Create("Atom.xml")
Dim atomFormatter As Atom10FeedFormatter(Of MySyndicationFeed) = New Atom10FeedFormatter(Of MySyndicationFeed)(feed)
atomFormatter.WriteTo(atomWriter)
atomWriter.Close()
注解
使用此类可以序列化 SyndicationFeed 派生类的实例,以及从包含 Atom 1.0 源的 XML 文档创建 SyndicationFeed 派生类的实例。 如果必须序列化 SyndicationFeed 实例,请改用 Atom10FeedFormatter 格式化程序。
注意
Atom 1.0 规范允许在其任何日期构造中指定秒的小数部分。 序列化和反序列化时,WCF 实现将忽略秒的小数部分。
构造函数
属性
DateTimeParser |
SyndicationFeedFormatter 类用来将 XmlDateTimeData 字符串数据转换为 DateTimeOffset 的委托。 (继承自 SyndicationFeedFormatter) |
Feed |
获取与格式化程序关联的 SyndicationFeed。 (继承自 SyndicationFeedFormatter) |
FeedType |
派生自与 SyndicationFeed 实例关联的 Atom10FeedFormatter 的实例。 (继承自 Atom10FeedFormatter) |
PreserveAttributeExtensions |
获取或设置一个值,该值指定是否在序列化过程中保留属性扩展。 (继承自 Atom10FeedFormatter) |
PreserveElementExtensions |
获取或设置一个值,该值指定是否在序列化过程中保留元素扩展。 (继承自 Atom10FeedFormatter) |
UriParser |
SyndicationFeedFormatter 类用来基于字符串输入创建 Uri 实例的委托。 (继承自 SyndicationFeedFormatter) |
Version |
获取格式化程序使用的联合版本。 (继承自 Atom10FeedFormatter) |