共用方式為


Rss20FeedFormatter 建構函式

定義

建立 Rss20FeedFormatter 類別的新執行個體。

多載

Rss20FeedFormatter()

建立 Rss20FeedFormatter 類別的新執行個體。

Rss20FeedFormatter(SyndicationFeed)

以指定的 Rss20FeedFormatter 執行個體建立 SyndicationFeed 類別的新執行個體。

Rss20FeedFormatter(Type)

建立 Rss20FeedFormatter 類別的新執行個體。

Rss20FeedFormatter(SyndicationFeed, Boolean)

以指定的 Rss20FeedFormatter 執行個體建立 SyndicationFeed 類別的新執行個體。

Rss20FeedFormatter()

建立 Rss20FeedFormatter 類別的新執行個體。

public:
 Rss20FeedFormatter();
public Rss20FeedFormatter ();
Public Sub New ()

範例

下列程式碼會示範如何建立 Rss20FeedFormatter 執行個體,並讀入 RSS 新聞訂閱摘要。

XmlReader rssReader = XmlReader.Create("http://contoso/Feeds/RSS/MyFeed");
Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter();
rssFormatter.ReadFrom(rssReader);
rssReader.Close();
Dim rssReader As XmlReader = XmlReader.Create("http://contoso/Feeds/RSS/MyFeed")
Dim rssFormatter As New Rss20FeedFormatter()
rssFormatter.ReadFrom(rssReader)
rssReader.Close()

適用於

Rss20FeedFormatter(SyndicationFeed)

以指定的 Rss20FeedFormatter 執行個體建立 SyndicationFeed 類別的新執行個體。

public:
 Rss20FeedFormatter(System::ServiceModel::Syndication::SyndicationFeed ^ feedToWrite);
public Rss20FeedFormatter (System.ServiceModel.Syndication.SyndicationFeed feedToWrite);
new System.ServiceModel.Syndication.Rss20FeedFormatter : System.ServiceModel.Syndication.SyndicationFeed -> System.ServiceModel.Syndication.Rss20FeedFormatter
Public Sub New (feedToWrite As SyndicationFeed)

參數

feedToWrite
SyndicationFeed

要序列化的 SyndicationFeed

範例

下列範例將示範如何呼叫這個建構函式。

    SyndicationFeed feed = new SyndicationFeed("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://Contoso/ItemOne"), "TestItemID", DateTime.Now);

List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
    feed.Items = items;

    XmlWriter rssWriter = XmlWriter.Create("RSS.xml");
    Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
Dim feed As SyndicationFeed = New SyndicationFeed("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://Contoso/ItemOne"), "TestItemID", DateTime.Now)

Dim items As List(Of SyndicationItem) = New List(Of SyndicationItem)()
items.Add(item)
feed.Items = items

Dim rssWriter As XmlWriter = XmlWriter.Create("RSS.xml")
Dim rssFormatter As Rss20FeedFormatter = New Rss20FeedFormatter(feed)

適用於

Rss20FeedFormatter(Type)

建立 Rss20FeedFormatter 類別的新執行個體。

public:
 Rss20FeedFormatter(Type ^ feedTypeToCreate);
public Rss20FeedFormatter (Type feedTypeToCreate);
new System.ServiceModel.Syndication.Rss20FeedFormatter : Type -> System.ServiceModel.Syndication.Rss20FeedFormatter
Public Sub New (feedTypeToCreate As Type)

參數

feedTypeToCreate
Type

要序列化的 SyndicationFeed 衍生執行個體。

範例

下列程式碼示範如何使用這個建構函式。

Rss20FeedFormatter myFeedRssFormatter = new Rss20FeedFormatter(typeof(MySyndicationFeed));
XmlReader rssReader = XmlReader.Create("http://Contoso/Feeds/MyFeed");
myFeedRssFormatter.ReadFrom(rssReader);
rssReader.Close();
Dim myFeedRssFormatter As New Rss20FeedFormatter(GetType(MySyndicationFeed))
Dim rssReader As XmlReader = XmlReader.Create("http://Contoso/Feeds/MyFeed")
myFeedRssFormatter.ReadFrom(rssReader)
rssReader.Close()

備註

您可以使用此建構函式,指定讀入新聞訂閱摘時要具現化的 SyndicationFeed 衍生類別。

適用於

Rss20FeedFormatter(SyndicationFeed, Boolean)

以指定的 Rss20FeedFormatter 執行個體建立 SyndicationFeed 類別的新執行個體。

public:
 Rss20FeedFormatter(System::ServiceModel::Syndication::SyndicationFeed ^ feedToWrite, bool serializeExtensionsAsAtom);
public Rss20FeedFormatter (System.ServiceModel.Syndication.SyndicationFeed feedToWrite, bool serializeExtensionsAsAtom);
new System.ServiceModel.Syndication.Rss20FeedFormatter : System.ServiceModel.Syndication.SyndicationFeed * bool -> System.ServiceModel.Syndication.Rss20FeedFormatter
Public Sub New (feedToWrite As SyndicationFeed, serializeExtensionsAsAtom As Boolean)

參數

feedToWrite
SyndicationFeed

要序列化的 SyndicationFeed

serializeExtensionsAsAtom
Boolean

一個值,指定是否要序列化在 Atom 1.0 規格中已定義,但在 RSS 2.0 規格中並未定義的項目。 預設值是 true

範例

下列範例將示範如何呼叫這個建構函式。

    SyndicationFeed feed = new SyndicationFeed("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://Contoso/ItemOne"), "TestItemID", DateTime.Now);

List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
    feed.Items = items;

    XmlWriter rssWriter = XmlWriter.Create("RSS.xml");
    Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed, true);
Dim feed As SyndicationFeed = New SyndicationFeed("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://Contoso/ItemOne"), "TestItemID", DateTime.Now)

Dim items As List(Of SyndicationItem) = New List(Of SyndicationItem)()
items.Add(item)
feed.Items = items

Dim rssWriter As XmlWriter = XmlWriter.Create("RSS.xml")
Dim rssFormatter As Rss20FeedFormatter = New Rss20FeedFormatter(feed, True)

備註

如果 serializeExtensionsAsAtom 參數為 true,則會使用 Atom 1.0 命名空間序列化在 Atom 1.0 規格中已定義、但是在 RSS 2.0 規格中未定義的所有項目。

適用於