SyndicationFeed Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Représente un objet de flux de niveau supérieur, <feed> dans Atom 1.0 et <rss> rss 2.0.
public ref class SyndicationFeed
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public class SyndicationFeed
public class SyndicationFeed
[<System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)>]
type SyndicationFeed = class
type SyndicationFeed = class
Public Class SyndicationFeed
- Héritage
-
SyndicationFeed
- Attributs
Exemples
Le code suivant montre comment créer une SyndicationFeed instance et la sérialiser sur Atom 1.0 et 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()
Le code XML suivant montre comment un SyndicationFeed est sérialisé vers 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>
Le code XML suivant montre comment une SyndicationFeed instance est sérialisée en RSS 2.0.
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
<channel CustomAttribute="Value">
<title>Feed Title</title>
<link>http://feed/Alternate/Link</link>
<description>This is a sample feed</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>Feed Title</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>Item Title</title>
<description>Some text content</description>
<a10:updated>2007-04-13T17:29:38Z</a10:updated>
</item>
</channel>
</rss>
Remarques
Lorsqu’elle est sérialisée dans Atom 1.0, une SyndicationFeed instance est écrite dans un <feed> élément. Le tableau suivant montre comment chaque propriété définie dans la SyndicationFeed classe est sérialisée sur Atom 1.0.
| SyndicationFeed, propriété | Formulaire sérialisé |
|---|---|
AttributeExtensions |
Attribut dans l’élément <feed> pour chaque attribut de la collection. |
Authors |
Élément <author> pour chaque SyndicationPerson élément de la collection. |
Categories |
Élément <category> pour chacun SyndicationCategory de la collection. |
Contributors |
Élément <contributor> pour chacun SyndicationPerson de la collection. |
Copyright |
Élément <rights> . |
Description |
Élément <subtitle> . |
ElementExtensions |
Chaque élément de la collection est écrit dans l’élément <feed> . |
Generator |
Élément <generator> . |
Id |
Élément <id> . |
ImageUri |
Élément <logo> . |
Items |
Élément <entry> pour chaque SyndicationItem élément de la collection. |
Language |
Non sérialisé. |
LastUpdatedTime |
Élément <updated> . |
Links |
Élément <link> pour chacun SyndicationLink de la collection. |
Title |
Élément <title> . |
Lorsqu’elle est sérialisée en RSS 2.0, une SyndicationFeed instance est écrite dans un <rss> élément. Le tableau suivant montre comment chaque propriété définie dans la SyndicationFeed classe est sérialisée en RSS 2.0.
| SyndicationFeed, propriété | Formulaire sérialisé |
|---|---|
AttributeExtensions |
Attribut dans l’élément <channel> pour chaque attribut de la collection. |
Authors |
Élément <managingEditor> si un SyndicationPerson seul est dans la collection ; sinon, un <a10:author> élément pour chacun SyndicationPerson dans la collection. |
Categories |
Élément <category> pour chacun SyndicationCategory de la collection. |
Contributors |
Élément <a10:contributor> pour chaque SyndicationPerson élément de la collection. |
Copyright |
Élément <copyright> . |
Description |
Élément <description> . |
ElementExtensions |
Chaque élément de la collection est écrit dans l’élément <channel> . |
Generator |
Élément <generator> . |
Id |
Élément <a10:id> . |
ImageUri |
Élément <image> . |
Items |
Élément <item> pour chaque SyndicationItem élément de la collection. |
Language |
Élément <language> . |
LastUpdatedTime |
Élément <lastBuildDate> . |
Links |
Élément <a10:link> pour chaque SyndicationLink élément de la collection. |
Title |
Élément <title> . |
Constructeurs
| Nom | Description |
|---|---|
| SyndicationFeed() |
Initialise une nouvelle instance de la classe SyndicationFeed. |
| SyndicationFeed(IEnumerable<SyndicationItem>) |
Initialise une nouvelle instance de la SyndicationFeed classe avec la collection d’objets SyndicationItem spécifiée. |
| SyndicationFeed(String, String, Uri, IEnumerable<SyndicationItem>) |
Initialise une nouvelle instance de la SyndicationFeed classe avec le titre, la description, l’URI et la collection d’objets SyndicationItem spécifiés. |
| SyndicationFeed(String, String, Uri, String, DateTimeOffset, IEnumerable<SyndicationItem>) |
Crée une instance de la SyndicationFeed classe. |
| SyndicationFeed(String, String, Uri, String, DateTimeOffset) |
Crée une instance de la SyndicationFeed classe. |
| SyndicationFeed(String, String, Uri) |
Initialise une nouvelle instance de la SyndicationFeed classe avec le titre, la description et l’URI spécifiés. |
| SyndicationFeed(SyndicationFeed, Boolean) |
Crée une instance de la SyndicationFeed classe avec le flux spécifié. |
Propriétés
| Nom | Description |
|---|---|
| AttributeExtensions |
Obtient une collection d’extensions d’attribut. |
| Authors |
Obtient une collection d’auteurs du flux. |
| BaseUri |
Obtient ou définit l’URI de base de l’instance SyndicationFeed . |
| Categories |
Obtient une collection de catégories pour le flux. |
| Contributors |
Obtient une collection des contributeurs au flux. |
| Copyright |
Obtient ou définit des informations de copyright pour le flux. |
| Description |
Obtient ou définit une description du flux. |
| Documentation |
Obtient ou définit le lien vers la documentation du flux. |
| ElementExtensions |
Obtient les extensions d’élément pour le flux. |
| Generator |
Obtient ou définit le générateur du flux. |
| Id |
Obtient ou définit l’ID du flux. |
| ImageUrl |
Obtient ou définit l’URL de l’image pour le flux. |
| Items |
Obtient une collection des éléments de flux contenus dans le flux. |
| Language |
Obtient ou définit la langue du flux. |
| LastUpdatedTime |
Obtient ou définit l’heure à laquelle le flux a été mis à jour pour la dernière fois. |
| Links |
Obtient les liens associés au flux. |
| SkipDays |
Obtient une collection de chaînes indiquant l’ensemble de valeurs dans l’élément « skipDays » pour le flux. |
| SkipHours |
Obtient une collection d’entiers indiquant l’ensemble de valeurs dans l’élément « skipHours » pour le flux. |
| TextInput |
Obtient ou définit la propriété TextInput pour le flux. |
| TimeToLive |
Obtient ou définit l’attribut « ttl » pour le flux. |
| Title |
Obtient ou définit le titre du flux. |
Méthodes
| Nom | Description |
|---|---|
| Clone(Boolean) |
Crée une copie de l’instance SyndicationFeed . |
| CreateCategory() |
Crée une nouvelle instance SyndicationCategory. |
| CreateItem() |
Crée une nouvelle instance SyndicationItem. |
| CreateLink() |
Crée une nouvelle instance SyndicationLink. |
| CreatePerson() |
Crée une nouvelle instance SyndicationPerson. |
| Equals(Object) |
Détermine si l’objet spécifié est égal à l’objet actuel. (Hérité de Object) |
| GetAtom10Formatter() |
Obtient une Atom10FeedFormatter instance. |
| GetHashCode() |
Sert de fonction de hachage par défaut. (Hérité de Object) |
| GetRss20Formatter() |
Obtient une Rss20FeedFormatter instance. |
| GetRss20Formatter(Boolean) |
Obtient une nouvelle Rss20FeedFormatter instance. |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| Load(XmlReader) |
Charge un flux de syndication à partir du lecteur XML spécifié. |
| Load<TSyndicationFeed>(XmlReader) |
Charge une SyndicationFeedinstance dérivée de l’objet spécifié XmlReader. |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| SaveAsAtom10(XmlWriter) |
Écrivez le flux de syndication au format Atom 1.0 spécifié XmlWriter . |
| SaveAsRss20(XmlWriter) |
Écrivez le flux de syndication au format RSS 2.0 spécifié XmlWriter . |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |
| TryParseAttribute(String, String, String, String) |
Tente d’analyser une extension d’attribut. |
| TryParseElement(XmlReader, String) |
Tente d’analyser une extension d’élément. |
| WriteAttributeExtensions(XmlWriter, String) |
Écrit les extensions d’attribut dans la version de XmlWriter syndication spécifiée. |
| WriteElementExtensions(XmlWriter, String) |
Écrit les extensions d’élément dans la version de XmlWriter syndication spécifiée. |