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 规范中未定义的所有元素进行序列化。

适用于