Rss20ItemFormatter<TSyndicationItem> 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
此類別可將 SyndicationItem 衍生的類別序列化為 RSS 2.0 格式,或自 RSS 2.0 序列化為原來的類別。
generic <typename TSyndicationItem>
where TSyndicationItem : SyndicationItemgcnew()public ref class Rss20ItemFormatter : System::ServiceModel::Syndication::Rss20ItemFormatter, System::Xml::Serialization::IXmlSerializable
generic <typename TSyndicationItem>
where TSyndicationItem : SyndicationItemgcnew()public ref class Rss20ItemFormatter : System::ServiceModel::Syndication::Rss20ItemFormatter
public class Rss20ItemFormatter<TSyndicationItem> : System.ServiceModel.Syndication.Rss20ItemFormatter, System.Xml.Serialization.IXmlSerializable where TSyndicationItem : SyndicationItem, new()
public class Rss20ItemFormatter<TSyndicationItem> : System.ServiceModel.Syndication.Rss20ItemFormatter where TSyndicationItem : SyndicationItem, new()
type Rss20ItemFormatter<'SyndicationItem (requires 'SyndicationItem :> SyndicationItem and 'SyndicationItem : (new : unit -> 'SyndicationItem))> = class
inherit Rss20ItemFormatter
interface IXmlSerializable
type Rss20ItemFormatter<'SyndicationItem (requires 'SyndicationItem :> SyndicationItem and 'SyndicationItem : (new : unit -> 'SyndicationItem))> = class
inherit Rss20ItemFormatter
Public Class Rss20ItemFormatter(Of TSyndicationItem)
Inherits Rss20ItemFormatter
Implements IXmlSerializable
Public Class Rss20ItemFormatter(Of TSyndicationItem)
Inherits Rss20ItemFormatter
類型參數
- TSyndicationItem
要序列化的 SyndicationItem 衍生型別。
- 繼承
- 實作
範例
下列程式碼範例會示範如何建立 SyndicationItem 衍生類別,並將這個類別序列化為 RSS 2.0。
MySyndicationItem item = new MySyndicationItem("Test Item", "This is the content for Test Item", new Uri("http://Contoso/ItemOne"), "TestItemID", DateTime.Now);
item.Links.Add(new SyndicationLink(new Uri("http://Contoso"), "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 rssWriter = XmlWriter.Create("RssItem.xml");
Rss20ItemFormatter<MySyndicationItem> formatter = new Rss20ItemFormatter<MySyndicationItem>(item);
formatter.WriteTo(rssWriter);
rssWriter.Close();
Dim item As MySyndicationItem = New MySyndicationItem("Test Item", "This is the content for Test Item", New Uri("http://Contoso/ItemOne"), "TestItemID", DateTime.Now)
item.Links.Add(New SyndicationLink(New Uri("http://Contoso"), "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 rssWriter As XmlWriter = XmlWriter.Create("RssItem.xml")
Dim formatter As Rss20ItemFormatter(Of MySyndicationItem) = New Rss20ItemFormatter(Of MySyndicationItem)(item)
formatter.WriteTo(rssWriter)
rssWriter.Close()
備註
您可以使用此類別序列化 SyndicationItem 衍生類別的執行個體,並且從表示 RSS 2.0 項目的 XML 文件,建立 SyndicationFeed 衍生類別的執行個體。 若您需要序列化 執行個體,請使用 格式器。
建構函式
屬性
Item |
取得與這個格式器相關聯的 SyndicationItem。 (繼承來源 SyndicationItemFormatter) |
ItemType |
取得與 Rss20ItemFormatter相關聯的新聞訂閱項目類型。 (繼承來源 Rss20ItemFormatter) |
PreserveAttributeExtensions |
取得或設定一個值,這個值會指定序列化期間是否保留屬性延伸。 (繼承來源 Rss20ItemFormatter) |
PreserveElementExtensions |
取得或設定一個值,這個值會指定序列化期間是否保留項目延伸。 (繼承來源 Rss20ItemFormatter) |
SerializeExtensionsAsAtom |
取得或設定值,指定是否要在 Atom 1.0 命名空間中序列化延伸模組。 (繼承來源 Rss20ItemFormatter) |
Version |
取得格式器所使用的新聞訂閱版本。 (繼承來源 Rss20ItemFormatter) |