.NET Framework Class Library
Rss20FeedFormatter<(Of <(TSyndicationFeed>)>) Class

A class that serializes SyndicationFeed-derived classes to RSS 2.0 format.

Namespace:  System.ServiceModel.Syndication
Assembly:  System.ServiceModel.Web (in System.ServiceModel.Web.dll)
Syntax

Visual Basic (Declaration)
Public Class Rss20FeedFormatter(Of TSyndicationFeed As {New, SyndicationFeed}) _
    Inherits Rss20FeedFormatter
Visual Basic (Usage)
Dim instance As Rss20FeedFormatter(Of TSyndicationFeed)
C#
public class Rss20FeedFormatter<TSyndicationFeed> : Rss20FeedFormatter
where TSyndicationFeed : new(), SyndicationFeed
Visual C++
generic<typename TSyndicationFeed>
where TSyndicationFeed : gcnew(), SyndicationFeed
public ref class Rss20FeedFormatter : public Rss20FeedFormatter
JScript
JScript does not support generic types or methods.

Type Parameters

TSyndicationFeed

The SyndicationFeed-derived type to serialize.

Remarks

Use this class to serialize instances of SyndicationFeed derived classes. If you need to serialize a SyndicationFeed instance, use the Rss20FeedFormatter formatter instead.

Examples

The following code shows how to create a SyndicationFeed derived class and serialize it to RSS 2.0.

Visual Basic
Dim feed As MySyndicationFeed = New MySyndicationFeed("Test Feed", "This is a test feed", New Uri("http://Contoso/testfeed"), "TestFeedID", DateTime.Now)
Dim item As SyndicationItem = New SyndicationItem("Test Item", "This is the content for Test Item", New Uri("http://Contoso/ItemOne"), "TestItemID", DateTime.Now)

item.Links.Add(New SyndicationLink(New Uri("http://Contoso"), "alternate", "MyItemLink", "text/html", 100))
item.PublishDate = New DateTime(1968, 2, 23)
item.LastUpdatedTime = DateTime.Today
item.SourceFeed = feed
item.Summary = New TextSyndicationContent("This the item summary")

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

Dim rssWriter As XmlWriter = XmlWriter.Create("Rss.xml")
Dim rssFormatter As Rss20FeedFormatter(Of MySyndicationFeed) = New Rss20FeedFormatter(Of MySyndicationFeed)(feed)
rssFormatter.WriteTo(rssWriter)
rssWriter.Close()
C#
            MySyndicationFeed feed = new MySyndicationFeed("Test Feed",
 "This is a test feed", new Uri("http://Contoso/testfeed"), "TestFeedID", DateTime.Now);

            SyndicationItem item = new SyndicationItem("Test Item", "This is the content for Test Item", new Uri("http://Contoso/ItemOne"), "TestItemID", DateTime.Now);

            item.Links.Add(new SyndicationLink(new Uri("http://Contoso"), "alternate", "MyItemLink", "text/html", 100));
            item.PublishDate = new DateTime(1968, 2, 23);
            item.LastUpdatedTime = DateTime.Today;
            item.SourceFeed = feed;
            item.Summary = new TextSyndicationContent("This the item summary");

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

            XmlWriter rssWriter = XmlWriter.Create("Rss.xml");
            Rss20FeedFormatter<MySyndicationFeed> rssFormatter = new Rss20FeedFormatter<MySyndicationFeed>(feed);
            rssFormatter.WriteTo(rssWriter);
            rssWriter.Close();
Inheritance Hierarchy

System..::.Object
  System.ServiceModel.Syndication..::.SyndicationFeedFormatter
    System.ServiceModel.Syndication..::.Rss20FeedFormatter
      System.ServiceModel.Syndication..::.Rss20FeedFormatter<(Of <(TSyndicationFeed>)>)
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5
See Also

Reference

Tags :


Page view tracker