Atom10ItemFormatter<TSyndicationItem> 类

定义

一个用于在 SyndicationItem 派生类与 Atom 1.0 格式之间来回序列化的类。

generic <typename TSyndicationItem>
 where TSyndicationItem : SyndicationItemgcnew()public ref class Atom10ItemFormatter : System::ServiceModel::Syndication::Atom10ItemFormatter
public class Atom10ItemFormatter<TSyndicationItem> : System.ServiceModel.Syndication.Atom10ItemFormatter where TSyndicationItem : SyndicationItem, new()
type Atom10ItemFormatter<'SyndicationItem (requires 'SyndicationItem :> SyndicationItem and 'SyndicationItem : (new : unit -> 'SyndicationItem))> = class
    inherit Atom10ItemFormatter
Public Class Atom10ItemFormatter(Of TSyndicationItem)
Inherits Atom10ItemFormatter

类型参数

TSyndicationItem

要序列化的 SyndicationItem 派生类。

继承
Atom10ItemFormatter<TSyndicationItem>

示例

下面的代码演示如何创建 SyndicationItem 派生类并将其序列化为 Atom 1.0。

MySyndicationItem item = new MySyndicationItem("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 = new SyndicationFeed();
item.Summary = new TextSyndicationContent("This the item summary");

XmlWriter atomWriter = XmlWriter.Create("AtomItem.xml");
Atom10ItemFormatter<MySyndicationItem> formatter = new Atom10ItemFormatter<MySyndicationItem>(item);
formatter.WriteTo(atomWriter);
atomWriter.Close();
Dim item As MySyndicationItem = New MySyndicationItem("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 = New SyndicationFeed()
item.Summary = New TextSyndicationContent("This the item summary")

Dim atomWriter As XmlWriter = XmlWriter.Create("AtomItem.xml")
Dim formatter As Atom10ItemFormatter(Of MySyndicationItem) = New Atom10ItemFormatter(Of MySyndicationItem)(item)
formatter.WriteTo(atomWriter)
atomWriter.Close()

注解

使用此类可以序列化 SyndicationItem 派生类的实例,以及从包含 Atom 1.0 项的 XML 文档创建 SyndicationFeed 派生类的实例。 如果必须序列化 SyndicationItem 实例,请改用 Atom10ItemFormatter 格式化程序。

备注

Atom 1.0 规范允许在其任何日期构造中指定秒的小数部分。 序列化和反序列化时,WCF 实现将忽略小数秒。

构造函数

Atom10ItemFormatter<TSyndicationItem>()

创建 Atom10ItemFormatter<TSyndicationItem> 类的新实例。

Atom10ItemFormatter<TSyndicationItem>(TSyndicationItem)

使用指定的 Atom10ItemFormatter<TSyndicationItem> 派生实例创建 SyndicationItem 类的新实例。

属性

Item

获取与格式化程序关联的 SyndicationItem

(继承自 SyndicationItemFormatter)
ItemType

获取与 Atom10ItemFormatter 关联的联合项类型。

(继承自 Atom10ItemFormatter)
PreserveAttributeExtensions

获取或设置一个值,该值指定是否在序列化过程中保留属性扩展。

(继承自 Atom10ItemFormatter)
PreserveElementExtensions

获取或设置一个值,该值指定是否在序列化过程中保留元素扩展。

(继承自 Atom10ItemFormatter)
Version

获取格式化程序使用的联合版本。

(继承自 Atom10ItemFormatter)

方法

CanRead(XmlReader)

验证指定的 XmlReader 是否包含有效的 Atom 1.0 联合项。

(继承自 Atom10ItemFormatter)
CreateItemInstance()

创建 SyndicationItem 派生类的新实例。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ReadFrom(XmlReader)

从指定的 XmlReader 实例读取 Atom 1.0 联合项。

(继承自 Atom10ItemFormatter)
SetItem(SyndicationItem)

SyndicationItem 实例与 SyndicationItemFormatter 相关联。

(继承自 SyndicationItemFormatter)
ToString()

获取 SyndicationItemFormatter 实例的字符串表示形式。

(继承自 SyndicationItemFormatter)
WriteElementExtensions(XmlWriter, SyndicationCategory, String)

使用指定的联合版本将 SyndicationCategory 实例中的元素扩展写入指定的 XmlWriter

(继承自 SyndicationItemFormatter)
WriteElementExtensions(XmlWriter, SyndicationLink, String)

使用指定的联合版本将 SyndicationLink 实例中的元素扩展写入指定的 XmlWriter

(继承自 SyndicationItemFormatter)
WriteElementExtensions(XmlWriter, SyndicationPerson, String)

使用指定的联合版本将 SyndicationPerson 实例中的元素扩展写入指定的 XmlWriter

(继承自 SyndicationItemFormatter)
WriteTo(XmlWriter)

将与 Atom10ItemFormatter 关联的 SyndicationItem 写入指定的 XmlWriter

(继承自 Atom10ItemFormatter)

显式接口实现

IXmlSerializable.GetSchema()

实现 GetSchema() 方法。

(继承自 Atom10ItemFormatter)
IXmlSerializable.ReadXml(XmlReader)

实现 ReadXml(XmlReader) 方法。

(继承自 Atom10ItemFormatter)
IXmlSerializable.WriteXml(XmlWriter)

实现 WriteXml(XmlWriter) 方法。

(继承自 Atom10ItemFormatter)

适用于