Rss20ItemFormatter 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建 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 规范中未定义的所有元素进行序列化。