SyndicationItem.Authors 属性

定义

获取联合项的作者。

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

属性值

一个表示联合项作者的 SyndicationPerson 对象集合。

示例

下面的代码演示如何将作者添加到 AuthorsSyndicationItem 集合。

SyndicationItem item = new SyndicationItem("Item Title", "Item Content", new Uri("http://Item/Alternate/Link"));
item.Authors.Add(new SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http://contoso/jesper"));
Dim item As New SyndicationItem("Item Title", "Item Content", New Uri("http:' Item/Alternate/Link"))
item.Authors.Add(New SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http:' contoso/jesper"))

下面的 XML 演示如何将前面的 SyndicationItem 序列化为 Atom 1.0。

<entry>
  <id>Item ID</id>
  <title type="text">My Item</title>
  <updated>2007-03-16T23:00:59Z</updated>
  <author>
    <name>Lene Aaling</name>
    <uri>http://contoso/Lene</uri>
    <email>lene@contoso.com</email>
  </author>
  <link rel="alternate" href="http://someserver/MyItem" />
  <link rel="alternate" type="text/html" title="Alternate Link" length="1000" href="http://otherserver/Item" />
  <content type="text">This is some content</content>
</entry>

下面的 XML 演示如何将前面的 SyndicationItem 序列化为 RSS 2.0。

<item>
  <guid isPermaLink="false">Item ID</guid>
  <link>http://someserver/MyItem</link>
  <author>someone@mycompany.com</author>
  <title>My Item</title>
  <description>This is some content</description>
  <a10:link rel="alternate" type="text/html" title="Alternate Link" length="1000" href="http://otherserver/Item" />
  <a10:updated>2007-03-16T23:00:59Z</a10:updated>
</item>

注解

序列化为 Atom 1.0 时,会针对 <author> 集合中的每个 SyndicationPerson 写入 Authors 元素。

序列化为 RSS 2.0 时, 如果Authors集合只有一个 <managingEditor>SyndicationPerson,则写入元素,否则为SyndicationPerson集合中的每个Authors元素写入一个<a10:author>元素。

适用于