Rss20ItemFormatter 构造函数
定义
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class.
重载
| Rss20ItemFormatter() |
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class. |
| Rss20ItemFormatter(SyndicationItem) |
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class. |
| Rss20ItemFormatter(Type) |
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class. |
| Rss20ItemFormatter(SyndicationItem, Boolean) |
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class. |
Rss20ItemFormatter()
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class.
public:
Rss20ItemFormatter();
public Rss20ItemFormatter ();
Public Sub New ()
适用于
Rss20ItemFormatter(SyndicationItem)
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class.
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。The SyndicationItem to serialize.
示例
下面的示例演示如何调用此构造函数。The following example shows how to call this constructor.
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 类的新实例。Creates a new instance of the Rss20ItemFormatter class.
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 的实例。The instance derived from SyndicationItem to associate with the Rss20ItemFormatter.
示例
下面的代码演示如何使用此构造函数。The following code shows how to use this constructor.
Rss20ItemFormatter myItemRssFormatter = new Rss20ItemFormatter(typeof(MySyndicationItem));
XmlReader rssReader = XmlReader.Create("http://Contoso/Feeds/MyFeed/Items");
myItemRssFormatter.ReadFrom(rssReader);
rssReader.Close();
注解
使用此构造函数可以指定要在读入联合项时实例化的 SyndicationItem 派生类。Use this constructor to specify a class derived from SyndicationItem to instantiate when a syndication item is read in.
适用于
Rss20ItemFormatter(SyndicationItem, Boolean)
创建 Rss20ItemFormatter 类的新实例。Creates a new instance of the Rss20ItemFormatter class.
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。The SyndicationItem to serialize.
- serializeExtensionsAsAtom
- Boolean
一个值,指定是否对在 Atom 1.0 规范中已定义但在 RSS 2.0 规范中未定义的元素进行序列化。A value that specifies whether to serialize elements that are defined in the Atom 1.0 specification but not in the RSS 2.0 specification. 默认值是 true。The default value is true.
示例
下面的示例演示如何调用此构造函数。The following example shows how to call this constructor.
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 规范中未定义的所有元素进行序列化。If the serializeExtensionsAsAtom parameter is true, all elements defined in the Atom 1.0 specification that are not defined in the RSS 2.0 specification are serialized with the Atom 1.0 namespace.