Sdílet prostřednictvím


Atom10FeedFormatter<TSyndicationFeed> Konstruktory

Definice

Vytvoří novou instanci třídy Atom10FeedFormatter<TSyndicationFeed>.

Přetížení

Atom10FeedFormatter<TSyndicationFeed>()

Vytvoří novou instanci třídy Atom10FeedFormatter<TSyndicationFeed>.

Atom10FeedFormatter<TSyndicationFeed>(TSyndicationFeed)

Vytvoří novou instanci Atom10FeedFormatter<TSyndicationFeed> třídy se zadanou SyndicationFeed-odvozenou instancí.

Atom10FeedFormatter<TSyndicationFeed>()

Vytvoří novou instanci třídy Atom10FeedFormatter<TSyndicationFeed>.

public:
 Atom10FeedFormatter();
public Atom10FeedFormatter ();
Public Sub New ()

Příklady

Následující kód ukazuje, jak vytvořit -odvozenou SyndicationFeedtřídu a serializovat ji na Atom 1.0.

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://localhost/ItemOne"), "TestItemID", DateTime.Now);

item.Links.Add(new SyndicationLink(new Uri("http://someuri"), "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 atomWriter = XmlWriter.Create("Atom.xml");
Atom10FeedFormatter<MySyndicationFeed> atomFormatter = new Atom10FeedFormatter<MySyndicationFeed>(feed);
atomFormatter.WriteTo(atomWriter);
atomWriter.Close();
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:'localhost/ItemOne"), "TestItemID", DateTime.Now)

item.Links.Add(New SyndicationLink(New Uri("http:'someuri"), "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 atomWriter As XmlWriter = XmlWriter.Create("Atom.xml")
Dim atomFormatter As Atom10FeedFormatter(Of MySyndicationFeed) = New Atom10FeedFormatter(Of MySyndicationFeed)(feed)
atomFormatter.WriteTo(atomWriter)
atomWriter.Close()

Platí pro

Atom10FeedFormatter<TSyndicationFeed>(TSyndicationFeed)

Vytvoří novou instanci Atom10FeedFormatter<TSyndicationFeed> třídy se zadanou SyndicationFeed-odvozenou instancí.

public:
 Atom10FeedFormatter(TSyndicationFeed feedToWrite);
public Atom10FeedFormatter (TSyndicationFeed feedToWrite);
new System.ServiceModel.Syndication.Atom10FeedFormatter<'SyndicationFeed (requires 'SyndicationFeed :> System.ServiceModel.Syndication.SyndicationFeed and 'SyndicationFeed : (new : unit -> 'SyndicationFeed))> : 'SyndicationFeed -> System.ServiceModel.Syndication.Atom10FeedFormatter<'SyndicationFeed (requires 'SyndicationFeed :> System.ServiceModel.Syndication.SyndicationFeed and 'SyndicationFeed : (new : unit -> 'SyndicationFeed))>
Public Sub New (feedToWrite As TSyndicationFeed)

Parametry

feedToWrite
TSyndicationFeed

Informační kanál, který se má serializovat.

Příklady

Následující kód ukazuje, jak vytvořit -odvozenou SyndicationFeedtřídu a serializovat ji na Atom 1.0.

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://localhost/ItemOne"), "TestItemID", DateTime.Now);

item.Links.Add(new SyndicationLink(new Uri("http://someuri"), "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 atomWriter = XmlWriter.Create("Atom.xml");
Atom10FeedFormatter<MySyndicationFeed> atomFormatter = new Atom10FeedFormatter<MySyndicationFeed>(feed);
atomFormatter.WriteTo(atomWriter);
atomWriter.Close();
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:'localhost/ItemOne"), "TestItemID", DateTime.Now)

item.Links.Add(New SyndicationLink(New Uri("http:'someuri"), "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 atomWriter As XmlWriter = XmlWriter.Create("Atom.xml")
Dim atomFormatter As Atom10FeedFormatter(Of MySyndicationFeed) = New Atom10FeedFormatter(Of MySyndicationFeed)(feed)
atomFormatter.WriteTo(atomWriter)
atomWriter.Close()

Platí pro