Rss20ItemFormatter 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立 Rss20ItemFormatter 類別的新執行個體。
多載
Rss20ItemFormatter() |
建立 Rss20ItemFormatter 類別的新執行個體。 |
Rss20ItemFormatter(SyndicationItem) |
建立 Rss20ItemFormatter 類別的新執行個體。 |
Rss20ItemFormatter(Type) |
建立 Rss20ItemFormatter 類別的新執行個體。 |
Rss20ItemFormatter(SyndicationItem, Boolean) |
建立 Rss20ItemFormatter 類別的新執行個體。 |
Rss20ItemFormatter()
建立 Rss20ItemFormatter 類別的新執行個體。
public:
Rss20ItemFormatter();
public Rss20ItemFormatter ();
Public Sub New ()
適用於
Rss20ItemFormatter(SyndicationItem)
建立 Rss20ItemFormatter 類別的新執行個體。
public:
Rss20ItemFormatter(System::ServiceModel::Syndication::SyndicationItem ^ itemToWrite);
public Rss20ItemFormatter (System.ServiceModel.Syndication.SyndicationItem itemToWrite);
new System.ServiceModel.Syndication.Rss20ItemFormatter : System.ServiceModel.Syndication.SyndicationItem -> System.ServiceModel.Syndication.Rss20ItemFormatter
Public Sub New (itemToWrite As SyndicationItem)
參數
- itemToWrite
- SyndicationItem
要序列化的 SyndicationItem。
範例
下列範例將示範如何呼叫這個建構函式。
SyndicationItem item = new SyndicationItem("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 formatter = new Rss20ItemFormatter(item);
Dim item As SyndicationItem = New SyndicationItem("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 = New Rss20ItemFormatter(item)
適用於
Rss20ItemFormatter(Type)
建立 Rss20ItemFormatter 類別的新執行個體。
public:
Rss20ItemFormatter(Type ^ itemTypeToCreate);
public Rss20ItemFormatter (Type itemTypeToCreate);
new System.ServiceModel.Syndication.Rss20ItemFormatter : Type -> System.ServiceModel.Syndication.Rss20ItemFormatter
Public Sub New (itemTypeToCreate As Type)
參數
- itemTypeToCreate
- Type
要與 SyndicationItem 相關聯的 Rss20ItemFormatter 衍生執行個體。
範例
下列程式碼示範如何使用這個建構函式。
Rss20ItemFormatter myItemRssFormatter = new Rss20ItemFormatter(typeof(MySyndicationItem));
XmlReader rssReader = XmlReader.Create("http://Contoso/Feeds/MyFeed/Items");
myItemRssFormatter.ReadFrom(rssReader);
rssReader.Close();
備註
您可以使用此建構函式,指定讀入新聞訂閱項目時要具現化的 SyndicationItem 衍生類別。
適用於
Rss20ItemFormatter(SyndicationItem, Boolean)
建立 Rss20ItemFormatter 類別的新執行個體。
public:
Rss20ItemFormatter(System::ServiceModel::Syndication::SyndicationItem ^ itemToWrite, bool serializeExtensionsAsAtom);
public Rss20ItemFormatter (System.ServiceModel.Syndication.SyndicationItem itemToWrite, bool serializeExtensionsAsAtom);
new System.ServiceModel.Syndication.Rss20ItemFormatter : System.ServiceModel.Syndication.SyndicationItem * bool -> System.ServiceModel.Syndication.Rss20ItemFormatter
Public Sub New (itemToWrite As SyndicationItem, serializeExtensionsAsAtom As Boolean)
參數
- itemToWrite
- SyndicationItem
要序列化的 SyndicationItem。
- serializeExtensionsAsAtom
- Boolean
一個值,指定是否要序列化在 Atom 1.0 規格中已定義,但在 RSS 2.0 規格中並未定義的項目。 預設值是 true
。
範例
下列範例將示範如何呼叫這個建構函式。
SyndicationItem item = new SyndicationItem("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 formatter = new Rss20ItemFormatter(item, true);
Dim item As SyndicationItem = New SyndicationItem("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 = New Rss20ItemFormatter(item, True)
備註
如果 serializeExtensionsAsAtom
參數為 true
,則會使用 Atom 1.0 命名空間序列化在 Atom 1.0 規格中已定義,但是在 RSS 2.0 規格中未定義的所有項目。