SyndicationFeed Třída

Definice

Představuje objekt informačního kanálu nejvyšší úrovně v <feed> atomu 1.0 a <rss> v RSS 2.0.

public ref class SyndicationFeed
public class SyndicationFeed
type SyndicationFeed = class
Public Class SyndicationFeed
Dědičnost
SyndicationFeed

Příklady

Následující kód ukazuje, jak vytvořit SyndicationFeed instanci a serializovat ji na Atom 1.0 i RSS 2.0.

SyndicationFeed feed = new SyndicationFeed("Feed Title", "Feed Description", new Uri("http://Feed/Alternate/Link"), "FeedID", DateTime.Now);
// Add a custom attribute.
XmlQualifiedName xqName = new XmlQualifiedName("CustomAttribute");
feed.AttributeExtensions.Add(xqName, "Value");

SyndicationPerson sp = new SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http://Jesper/Aaberg");
feed.Authors.Add(sp);

SyndicationCategory category = new SyndicationCategory("FeedCategory", "CategoryScheme", "CategoryLabel");
feed.Categories.Add(category);

feed.Contributors.Add(new SyndicationPerson("lene@contoso.com", "Lene Aaling", "http://lene/aaling"));
feed.Copyright = new TextSyndicationContent("Copyright 2007");
feed.Description = new TextSyndicationContent("This is a sample feed");

// Add a custom element.
XmlDocument doc = new XmlDocument();
XmlElement feedElement = doc.CreateElement("CustomElement");
feedElement.InnerText = "Some text";
feed.ElementExtensions.Add(feedElement);

feed.Generator = "Sample Code";
feed.Id = "FeedID";
feed.ImageUrl = new Uri("http://server/image.jpg");

TextSyndicationContent textContent = new TextSyndicationContent("Some text content");
SyndicationItem item = new SyndicationItem("Item Title", textContent, new Uri("http://server/items"), "ItemID", DateTime.Now);

List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
feed.Items = items;

feed.Language = "en-us";
feed.LastUpdatedTime = DateTime.Now;

SyndicationLink link = new SyndicationLink(new Uri("http://server/link"), "alternate", "Link Title", "text/html", 1000);
feed.Links.Add(link);

XmlWriter atomWriter = XmlWriter.Create("atom.xml");
Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(feed);
atomFormatter.WriteTo(atomWriter);
atomWriter.Close();

XmlWriter rssWriter = XmlWriter.Create("rss.xml");
Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
rssFormatter.WriteTo(rssWriter);
rssWriter.Close();
Dim feed As SyndicationFeed = New SyndicationFeed("Feed Title", "Feed Description", New Uri("http:'Feed/Alternate/Link"), "FeedID", DateTime.Now)
' Add a custom attribute.
Dim xqName As XmlQualifiedName = New XmlQualifiedName("CustomAttribute")
feed.AttributeExtensions.Add(xqName, "Value")

Dim sp As SyndicationPerson = New SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http:'jesper/aaberg")
feed.Authors.Add(sp)

Dim category As SyndicationCategory = New SyndicationCategory("FeedCategory", "CategoryScheme", "CategoryLabel")
feed.Categories.Add(category)

feed.Contributors.Add(New SyndicationPerson("Lene@contoso.com", "Lene Aaling", "http:'Lene/Aaling"))
feed.Copyright = New TextSyndicationContent("Copyright 2007")
feed.Description = New TextSyndicationContent("This is a sample feed")

' Add a custom element.
Dim doc As XmlDocument = New XmlDocument()
Dim feedElement As XmlElement = doc.CreateElement("CustomElement")
feedElement.InnerText = "Some text"
feed.ElementExtensions.Add(feedElement)

feed.Generator = "Sample Code"
feed.Id = "FeedID"
feed.ImageUrl = New Uri("http:'server/image.jpg")

Dim textContent As TextSyndicationContent = New TextSyndicationContent("Some text content")
Dim item As SyndicationItem = New SyndicationItem("Item Title", textContent, New Uri("http:'server/items"), "ItemID", DateTime.Now)

Dim items As Collection(Of SyndicationItem) = New Collection(Of SyndicationItem)()
items.Add(item)
feed.Items = items

feed.Language = "en-us"
feed.LastUpdatedTime = DateTime.Now

Dim link As SyndicationLink = New SyndicationLink(New Uri("http:'server/link"), "alternate", "Link Title", "text/html", 1000)
feed.Links.Add(link)

Dim atomWriter As XmlWriter = XmlWriter.Create("atom.xml")
Dim atomFormatter As Atom10FeedFormatter = New Atom10FeedFormatter(feed)
atomFormatter.WriteTo(atomWriter)
atomWriter.Close()

Dim rssWriter As XmlWriter = XmlWriter.Create("rss.xml")
Dim rssFormatter As Rss20FeedFormatter = New Rss20FeedFormatter(feed)
rssFormatter.WriteTo(rssWriter)
rssWriter.Close()

Následující XML ukazuje, jak SyndicationFeed je serializován na Atom 1.0.

<feed xml:lang="en-us" CustomAttribute="Value" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Feed Title</title>
  <subtitle type="text">This is a sample feed</subtitle>
  <id>FeedID</id>

  <rights type="text">Copyright 2007</rights>
  <updated>2007-04-13T17:29:38Z</updated>
  <category term="FeedCategory" label="CategoryLabel" scheme="CategoryScheme" />
  <logo>http://contoso/image.jpg</logo>
  <author>
    <name>Jesper Aaberg</name>
    <uri>http://contoso/Aaberg</uri>
    <email>Jesper.Asberg@contoso.com</email>
  </author>
  <contributor>
    <name>Lene Aalling</name>
    <uri>http://contoso/Aalling</uri>
    <email>Lene.Aaling@contoso.com</email>
  </contributor>
  <generator>Sample Code</generator>
  <link rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />

  <link customAttribute="value" rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
  <CustomElement xmlns="">Some text</CustomElement>
  <entry>
    <id>ItemID</id>
    <title type="text">Item Title</title>
    <updated>2007-04-13T17:29:38Z</updated>
    <link rel="alternate" href="http://contoso/items" />
    <content type="text">Some text content</content>
  </entry>

</feed>

Následující XML ukazuje, jak SyndicationFeed je instance serializována na RSS 2.0.

<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel CustomAttribute="Value">
    <title>Název informačního kanálu</title>
    <link>http://feed/Alternate/Link</link>
    <description>Toto je ukázkový informační kanál.</description>
    <language>en-us</language>

    <copyright>Copyright 2007</copyright>

    <managingEditor>Jesper.Aaberg@contoso.com</managingEditor>
    <lastBuildDate>Fri, 13 Apr 2007 17:29:38 Z</lastBuildDate>
    <category domain="CategoryScheme">FeedCategory</category>
    <a10:link rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
    <generator>Sample Code</generator>
    
    <a10:contributor>
      <a10:name>Lene Aalling</a10:name>
      <a10:uri>http://contoso/Aalling</a10:uri>
      <a10:email>Lene.Aalling@contoso.com</a10:email>
    </a10:contributor>
    
    <a10:author>
      <a10:name>Lene Aalling</a10:name>
      <a10:uri>http://contoso/Aalling</a10:uri>
      <a10:email>Lene.Aalling@contoso.com</a10:email>
    </a10:author>
    <image>
      <url>http://contoso/image.jpg</url>
      <title>Název informačního kanálu</title>
      <link>http://feed/Alternate/Link</link>
    </image>
    <a10:id>FeedID</a10:id>
    <a10:link customAttribute="value" rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
    
    <CustomElement>Some text</CustomElement>
    <item>
      <guid isPermaLink="false">ItemID</guid>
      <link>http://contoso/items</link>
      <title>Název položky</title>
      <description>Obsah textu</description>
      <a10:updated>2007-04-13T17:29:38Z</a10:updated>
    </item>
  </channel>
</rss>

Poznámky

Při serializaci na Atom 1.0 je SyndicationFeed instance zapsána do elementu <feed> . Následující tabulka ukazuje, jak se každá vlastnost definovaná ve SyndicationFeed třídě serializuje na Atom 1.0.

SyndicationFeed – vlastnost Serializovaný formulář
AttributeExtensions Atribut v elementu <feed> pro každý atribut v kolekci.
Authors Prvek <author> pro každý SyndicationPerson z nich v kolekci.
Categories Prvek <category> pro každý SyndicationCategory z nich v kolekci.
Contributors Prvek <contributor> pro každý SyndicationPerson z nich v kolekci.
Copyright Prvek.<rights>
Description Prvek.<subtitle>
ElementExtensions Každý prvek v kolekci je zapsán v elementu <feed> .
Generator Prvek.<generator>
Id Prvek <id> .
ImageUri Prvek.<logo>
Items Prvek <entry> pro každý SyndicationItem z nich v kolekci.
Language Serializováno není.
LastUpdatedTime Prvek <updated> .
Links Prvek <link> pro každý SyndicationLink z nich v kolekci.
Title Prvek.<title>

Při serializaci rss 2.0 je SyndicationFeed instance zapsána do elementu <rss> . Následující tabulka ukazuje, jak se každá vlastnost definovaná ve SyndicationFeed třídě serializuje na RSS 2.0.

SyndicationFeed – vlastnost Serializovaný formulář
AttributeExtensions Atribut v elementu <channel> pro každý atribut v kolekci.
Authors Prvek <managingEditor> , pokud je v kolekci pouze jeden SyndicationPerson , v opačném případě <a10:author> prvek pro každý SyndicationPerson z nich v kolekci.
Categories Prvek <category> pro každý SyndicationCategory z nich v kolekci.
Contributors Prvek <a10:contributor> pro každý SyndicationPerson z nich v kolekci.
Copyright Prvek.<copyright>
Description Prvek.<description>
ElementExtensions Každý prvek v kolekci je zapsán v elementu <channel> .
Generator Prvek.<generator>
Id Prvek <a10:id> .
ImageUri Prvek <image> .
Items Prvek <item> pro každý SyndicationItem z nich v kolekci.
Language Prvek.<language>
LastUpdatedTime Prvek.<lastBuildDate>
Links Prvek <a10:link> pro každý SyndicationLink z nich v kolekci.
Title Prvek.<title>

Konstruktory

SyndicationFeed()

Inicializuje novou instanci SyndicationFeed třídy.

SyndicationFeed(IEnumerable<SyndicationItem>)

Inicializuje novou instanci SyndicationFeed třídy se zadanou kolekcí SyndicationItem objektů.

SyndicationFeed(String, String, Uri)

Inicializuje novou instanci SyndicationFeed třídy se zadaným názvem, popisem a identifikátorem URI (Uniform Resource Identifier).

SyndicationFeed(String, String, Uri, IEnumerable<SyndicationItem>)

Inicializuje novou instanci SyndicationFeed třídy se zadaným názvem, popisem, identifikátorem URI a kolekcí SyndicationItem objektů.

SyndicationFeed(String, String, Uri, String, DateTimeOffset)

Vytvoří novou instanci třídy SyndicationFeed.

SyndicationFeed(String, String, Uri, String, DateTimeOffset, IEnumerable<SyndicationItem>)

Vytvoří novou instanci třídy SyndicationFeed.

SyndicationFeed(SyndicationFeed, Boolean)

Vytvoří novou instanci SyndicationFeed třídy se zadaným informačním kanálem.

Vlastnosti

AttributeExtensions

Získá kolekci rozšíření atributů.

Authors

Získá kolekci autorů informačního kanálu.

BaseUri

Získá nebo nastaví základní identifikátor URI instance SyndicationFeed .

Categories

Získá kolekci kategorií pro informační kanál.

Contributors

Získá kolekci přispěvatelů do informačního kanálu.

Copyright

Získá nebo nastaví informace o autorských právech pro informační kanál.

Description

Získá nebo nastaví popis kanálu.

Documentation

Získá nebo nastaví odkaz na dokumentaci pro informační kanál.

ElementExtensions

Získá rozšíření elementu pro informační kanál.

Generator

Získá nebo nastaví generátor kanálu.

Id

Získá nebo nastaví ID informačního kanálu.

ImageUrl

Získá nebo nastaví adresu URL obrázku pro informační kanál.

Items

Získá kolekci položek informačního kanálu obsažených v informačním kanálu.

Language

Získá nebo nastaví jazyk kanálu.

LastUpdatedTime

Získá nebo nastaví čas poslední aktualizace informačního kanálu.

Links

Získá odkazy přidružené k informačnímu kanálu.

SkipDays

Získá kolekci řetězců označující sadu hodnot v elementu skipDays pro informační kanál.

SkipHours

Získá kolekci celých čísel označujících sadu hodnot v elementu skipHours pro informační kanál.

TextInput

Získá nebo nastaví TextInput vlastnost informačního kanálu.

TimeToLive

Získá nebo nastaví atribut ttl pro informační kanál.

Title

Získá nebo nastaví název informačního kanálu.

Metody

Clone(Boolean)

Vytvoří kopii SyndicationFeed instance.

CreateCategory()

Vytvoří novou instanci sloupce SyndicationCategory.

CreateItem()

Vytvoří novou instanci sloupce SyndicationItem.

CreateLink()

Vytvoří novou instanci sloupce SyndicationLink.

CreatePerson()

Vytvoří novou instanci sloupce SyndicationPerson.

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetAtom10Formatter()

Atom10FeedFormatter Získá instanci.

GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetRss20Formatter()

Rss20FeedFormatter Získá instanci.

GetRss20Formatter(Boolean)

Získá novou Rss20FeedFormatter instanci.

GetType()

Type Získá aktuální instanci.

(Zděděno od Object)
Load(XmlReader)

Načte kanál syndikace ze zadané čtečky XML.

Load<TSyndicationFeed>(XmlReader)

Načte instanci odvozenou SyndicationFeedod zadaného XmlReaderobjektu .

MemberwiseClone()

Vytvoří použádnou kopii aktuálního souboru Object.

(Zděděno od Object)
SaveAsAtom10(XmlWriter)

Napište kanál syndikace do zadaného XmlWriter formátu Atom 1.0.

SaveAsRss20(XmlWriter)

Napište kanál syndikace do zadaného XmlWriter formátu RSS 2.0.

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)
TryParseAttribute(String, String, String, String)

Pokouší se parsovat rozšíření atributů.

TryParseElement(XmlReader, String)

Pokusí se parsovat rozšíření elementu.

WriteAttributeExtensions(XmlWriter, String)

Zapíše rozšíření atributů do zadané XmlWriter verze syndikace.

WriteElementExtensions(XmlWriter, String)

Zapíše rozšíření elementu do zadané XmlWriter verze syndikace.

Platí pro