Share via


SyndicationFeed.Categories 属性

定义

获取源类别的集合。

public:
 property System::Collections::ObjectModel::Collection<System::ServiceModel::Syndication::SyndicationCategory ^> ^ Categories { System::Collections::ObjectModel::Collection<System::ServiceModel::Syndication::SyndicationCategory ^> ^ get(); };
public System.Collections.ObjectModel.Collection<System.ServiceModel.Syndication.SyndicationCategory> Categories { get; }
member this.Categories : System.Collections.ObjectModel.Collection<System.ServiceModel.Syndication.SyndicationCategory>
Public ReadOnly Property Categories As Collection(Of SyndicationCategory)

属性值

一个表示源类别的 SyndicationCategory 对象集合。

示例

下面的代码演示如何将类别添加到 CategoriesSyndicationFeed 集合。

SyndicationFeed feed = new SyndicationFeed("Feed Title", "Feed Description", new Uri("http://Feed/Alternate/Link"), "FeedID", DateTime.Now);
feed.Categories.Add(new SyndicationCategory("MyFeedCategory"));
Dim feed As New SyndicationFeed("Feed Title", "Feed Description", New Uri("http:'Feed/Alternate/Link"), "FeedID", DateTime.Now)
feed.Categories.Add(New SyndicationCategory("MyFeedCategory"))

下面的 XML 演示如何将 Categories 集合序列化为 Atom 1.0。

<category term="FeedCategory" label="CategoryLabel" scheme="CategoryScheme" />

下面的 XML 演示如何将 Categories 集合序列化为 RSS 2.0。

<category domain="CategoryScheme">FeedCategory</category>

注解

序列化为 Atom 1.0 时, SyndicationCategory 集合中的每个都会写入 <category> 元素。

序列化为 RSS 2.0 时, SyndicationCategory 集合中的每个都写入元素 <category>

适用于