SyndicationFeed Klasa

Definicja

Reprezentuje obiekt kanału informacyjnego najwyższego poziomu w <feed> atomach 1.0 i <rss> RSS 2.0.

public ref class SyndicationFeed
public class SyndicationFeed
type SyndicationFeed = class
Public Class SyndicationFeed
Dziedziczenie
SyndicationFeed

Przykłady

Poniższy kod pokazuje, jak utworzyć SyndicationFeed wystąpienie i serializować je zarówno do atomów 1.0, jak 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()

Poniższy kod XML pokazuje, jak SyndicationFeed jest serializowany do atomu 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>

Poniższy kod XML pokazuje, jak SyndicationFeed wystąpienie jest serializowane do rss 2.0.

<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel CustomAttribute="Value">
    <title>Tytuł kanału informacyjnego</title>
    <link>http://feed/Alternate/Link</link>
    <description>Jest to przykładowy kanał informacyjny</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>Tytuł kanału informacyjnego</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>Tytuł elementu</title>
      <description>Część zawartości tekstowej</description>
      <a10:updated>2007-04-13T17:29:38Z</a10:updated>
    </item>
  </channel>
</rss>

Uwagi

Po serializacji do atomu 1.0 SyndicationFeed wystąpienie jest zapisywane w elemencie <feed> . W poniższej tabeli pokazano, jak każda właściwość zdefiniowana w klasie jest serializowana do atomu SyndicationFeed 1.0.

Właściwość SyndicationFeed Formularz serializowany
AttributeExtensions Atrybut w <feed> elemecie dla każdego atrybutu w kolekcji.
Authors Element <author> dla każdej SyndicationPerson z nich w kolekcji.
Categories Element <category> dla każdej SyndicationCategory z nich w kolekcji.
Contributors Element <contributor> dla każdej SyndicationPerson z nich w kolekcji.
Copyright Element <rights> .
Description Element <subtitle> .
ElementExtensions Każdy element w kolekcji jest zapisywany w elemecie <feed> .
Generator Element <generator> .
Id Element <id> .
ImageUri Element <logo> .
Items Element <entry> dla każdej SyndicationItem z nich w kolekcji.
Language Nie serializowane.
LastUpdatedTime Element <updated> .
Links Element <link> dla każdej SyndicationLink z nich w kolekcji.
Title Element <title> .

Po serializacji do rss 2.0 SyndicationFeed wystąpienie jest zapisywane w elemecie <rss> . W poniższej SyndicationFeed tabeli pokazano, jak każda właściwość zdefiniowana w klasie jest serializowana do funkcji RSS 2.0.

Właściwość SyndicationFeed Formularz serializowany
AttributeExtensions Atrybut w <channel> elemecie dla każdego atrybutu w kolekcji.
Authors Element <managingEditor> , jeśli tylko jeden SyndicationPerson znajduje się w kolekcji; w przeciwnym razie <a10:author> element dla każdej SyndicationPerson z nich w kolekcji.
Categories Element <category> dla każdej SyndicationCategory z nich w kolekcji.
Contributors Element <a10:contributor> dla każdej SyndicationPerson z nich w kolekcji.
Copyright Element <copyright> .
Description Element <description> .
ElementExtensions Każdy element w kolekcji jest zapisywany w elemecie <channel> .
Generator Element <generator> .
Id Element <a10:id> .
ImageUri Element <image> .
Items Element <item> dla każdej SyndicationItem z nich w kolekcji.
Language Element <language> .
LastUpdatedTime Element <lastBuildDate> .
Links Element <a10:link> dla każdej SyndicationLink z nich w kolekcji.
Title Element <title> .

Konstruktory

SyndicationFeed()

Inicjuje nowe wystąpienie klasy SyndicationFeed.

SyndicationFeed(IEnumerable<SyndicationItem>)

Inicjuje SyndicationFeed nowe wystąpienie klasy z określoną kolekcją SyndicationItem obiektów.

SyndicationFeed(String, String, Uri)

Inicjuje SyndicationFeed nowe wystąpienie klasy o określonym tytule, opisie i identyfikatorze ujednoliconego zasobu (URI).

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

Inicjuje SyndicationFeed nowe wystąpienie klasy o określonym tytule, opisie, identyfikatorze URI i kolekcji SyndicationItem obiektów.

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

Tworzy nowe wystąpienie klasy SyndicationFeed.

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

Tworzy nowe wystąpienie klasy SyndicationFeed.

SyndicationFeed(SyndicationFeed, Boolean)

Tworzy nowe wystąpienie SyndicationFeed klasy z określonym kanałem informacyjnym.

Właściwości

AttributeExtensions

Pobiera kolekcję rozszerzeń atrybutów.

Authors

Pobiera kolekcję autorów kanału informacyjnego.

BaseUri

Pobiera lub ustawia podstawowy identyfikator URI dla SyndicationFeed wystąpienia.

Categories

Pobiera kolekcję kategorii kanału informacyjnego.

Contributors

Pobiera kolekcję współautorów kanału informacyjnego.

Copyright

Pobiera lub ustawia informacje o prawach autorskich dla kanału informacyjnego.

Description

Pobiera lub ustawia opis kanału informacyjnego.

Documentation

Pobiera lub ustawia link do dokumentacji źródła danych.

ElementExtensions

Pobiera rozszerzenia elementu dla źródła danych.

Generator

Pobiera lub ustawia generator źródła danych.

Id

Pobiera lub ustawia identyfikator kanału informacyjnego.

ImageUrl

Pobiera lub ustawia adres URL obrazu dla kanału informacyjnego.

Items

Pobiera kolekcję elementów kanału informacyjnego zawartych w kanale informacyjnym.

Language

Pobiera lub ustawia język kanału informacyjnego.

LastUpdatedTime

Pobiera lub ustawia czas ostatniej aktualizacji kanału informacyjnego.

Links

Pobiera linki skojarzone z kanałem informacyjnym.

SkipDays

Pobiera kolekcję ciągów wskazujących zestaw wartości w elemecie "skipDays" dla źródła danych.

SkipHours

Pobiera kolekcję liczb całkowitych wskazujących zestaw wartości w elemecie "skipHours" dla kanału informacyjnego.

TextInput

Pobiera lub ustawia właściwość TextInput dla kanału informacyjnego.

TimeToLive

Pobiera lub ustawia atrybut "ttl" dla kanału informacyjnego.

Title

Pobiera lub ustawia tytuł kanału informacyjnego.

Metody

Clone(Boolean)

Tworzy kopię SyndicationFeed wystąpienia.

CreateCategory()

Tworzy nowe wystąpienie klasy SyndicationCategory.

CreateItem()

Tworzy nowe wystąpienie klasy SyndicationItem.

CreateLink()

Tworzy nowe wystąpienie klasy SyndicationLink.

CreatePerson()

Tworzy nowe wystąpienie klasy SyndicationPerson.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetAtom10Formatter()

Atom10FeedFormatter Pobiera wystąpienie.

GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetRss20Formatter()

Rss20FeedFormatter Pobiera wystąpienie.

GetRss20Formatter(Boolean)

Pobiera nowe Rss20FeedFormatter wystąpienie.

GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
Load(XmlReader)

Ładuje źródło danych syndykacji z określonego czytnika XML.

Load<TSyndicationFeed>(XmlReader)

SyndicationFeedŁaduje wystąpienie pochodne z określonego XmlReaderobiektu .

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
SaveAsAtom10(XmlWriter)

Zapisz źródło danych syndykacji do określonego XmlWriter w formacie Atom 1.0.

SaveAsRss20(XmlWriter)

Zapisz źródło danych syndykacji do określonego XmlWriter w formacie RSS 2.0.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
TryParseAttribute(String, String, String, String)

Próbuje przeanalizować rozszerzenie atrybutu.

TryParseElement(XmlReader, String)

Próbuje przeanalizować rozszerzenie elementu.

WriteAttributeExtensions(XmlWriter, String)

Zapisuje rozszerzenia atrybutów do określonej XmlWriter przy użyciu określonej wersji syndykacji.

WriteElementExtensions(XmlWriter, String)

Zapisuje rozszerzenia elementu do określonej XmlWriter przy użyciu określonej wersji syndykacji.

Dotyczy