Freigeben über


Atom10FeedFormatter<TSyndicationFeed> Konstruktoren

Definition

Erstellt eine neue Instanz der Atom10FeedFormatter<TSyndicationFeed>-Klasse.

Überlädt

Atom10FeedFormatter<TSyndicationFeed>()

Erstellt eine neue Instanz der Atom10FeedFormatter<TSyndicationFeed>-Klasse.

Atom10FeedFormatter<TSyndicationFeed>(TSyndicationFeed)

Erstellt eine neue Instanz der Klasse Atom10FeedFormatter<TSyndicationFeed> mit der angegebenen, von SyndicationFeed abgeleiteten Instanz.

Atom10FeedFormatter<TSyndicationFeed>()

Erstellt eine neue Instanz der Atom10FeedFormatter<TSyndicationFeed>-Klasse.

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

Beispiele

Der folgende Code zeigt die Erstellung einer aus SyndicationFeed abgeleiteten Klasse und deren Serialisierung zu 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()

Gilt für

Atom10FeedFormatter<TSyndicationFeed>(TSyndicationFeed)

Erstellt eine neue Instanz der Klasse Atom10FeedFormatter<TSyndicationFeed> mit der angegebenen, von SyndicationFeed abgeleiteten Instanz.

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)

Parameter

feedToWrite
TSyndicationFeed

Der zu serialisierende Feed.

Beispiele

Der folgende Code zeigt die Erstellung einer aus SyndicationFeed abgeleiteten Klasse und deren Serialisierung zu 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()

Gilt für