Rss20FeedFormatter<TSyndicationFeed> 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
一个用于将 SyndicationFeed 派生类序列化为 RSS 2.0 格式的类。
generic <typename TSyndicationFeed>
where TSyndicationFeed : SyndicationFeedgcnew()public ref class Rss20FeedFormatter : System::ServiceModel::Syndication::Rss20FeedFormatter
public class Rss20FeedFormatter<TSyndicationFeed> : System.ServiceModel.Syndication.Rss20FeedFormatter where TSyndicationFeed : SyndicationFeed, new()
type Rss20FeedFormatter<'SyndicationFeed (requires 'SyndicationFeed :> SyndicationFeed and 'SyndicationFeed : (new : unit -> 'SyndicationFeed))> = class
inherit Rss20FeedFormatter
Public Class Rss20FeedFormatter(Of TSyndicationFeed)
Inherits Rss20FeedFormatter
类型参数
- TSyndicationFeed
要序列化的 SyndicationFeed 派生类型。
- 继承
示例
下面的代码演示如何创建 SyndicationFeed 派生类并将其序列化为 RSS 2.0。
MySyndicationFeed feed = new MySyndicationFeed("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);
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 = feed;
item.Summary = new TextSyndicationContent("This the item summary");
List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
feed.Items = items;
XmlWriter rssWriter = XmlWriter.Create("Rss.xml");
Rss20FeedFormatter<MySyndicationFeed> rssFormatter = new Rss20FeedFormatter<MySyndicationFeed>(feed);
rssFormatter.WriteTo(rssWriter);
rssWriter.Close();
Dim feed As MySyndicationFeed = New MySyndicationFeed("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)
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 = feed
item.Summary = New TextSyndicationContent("This the item summary")
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(Of MySyndicationFeed) = New Rss20FeedFormatter(Of MySyndicationFeed)(feed)
rssFormatter.WriteTo(rssWriter)
rssWriter.Close()
注解
使用此类可以序列化 SyndicationFeed 派生类的实例。 如果需要序列化 SyndicationFeed 实例,请改用 Rss20FeedFormatter 格式化程序。
构造函数
属性
DateTimeParser |
SyndicationFeedFormatter 类用来将 XmlDateTimeData 字符串数据转换为 DateTimeOffset 的委托。 (继承自 SyndicationFeedFormatter) |
Feed |
获取与格式化程序关联的 SyndicationFeed。 (继承自 SyndicationFeedFormatter) |
FeedType |
派生自与 SyndicationFeed 实例关联的 Rss20FeedFormatter 的实例。 (继承自 Rss20FeedFormatter) |
PreserveAttributeExtensions |
获取或设置一个值,该值指定是否在序列化过程中保留属性扩展。 (继承自 Rss20FeedFormatter) |
PreserveElementExtensions |
获取或设置一个值,该值指定是否在序列化过程中保留元素扩展。 (继承自 Rss20FeedFormatter) |
SerializeExtensionsAsAtom |
获取或设置一个值,该值指定是否在 Atom 1.0 命名空间中序列化扩展。 (继承自 Rss20FeedFormatter) |
UriParser |
SyndicationFeedFormatter 类用来基于字符串输入创建 Uri 实例的委托。 (继承自 SyndicationFeedFormatter) |
Version |
获取格式化程序使用的联合版本。 (继承自 Rss20FeedFormatter) |