SyndicationItem.ElementExtensions Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar elementtilläggen i syndikeringsobjektet.
public:
property System::ServiceModel::Syndication::SyndicationElementExtensionCollection ^ ElementExtensions { System::ServiceModel::Syndication::SyndicationElementExtensionCollection ^ get(); };
public System.ServiceModel.Syndication.SyndicationElementExtensionCollection ElementExtensions { get; }
member this.ElementExtensions : System.ServiceModel.Syndication.SyndicationElementExtensionCollection
Public ReadOnly Property ElementExtensions As SyndicationElementExtensionCollection
Egenskapsvärde
En SyndicationElementExtensionCollection som innehåller elementtilläggen.
Exempel
Följande kod visar hur du lägger till elementtillägg till en SyndicationItem instans.
SyndicationItem item = new SyndicationItem();
// Add several different types of element extensions
item.ElementExtensions.Add("simpleString", "", "hello, world!");
item.ElementExtensions.Add("simpleString", "", "another simple string");
// DataContractExtension is a user-defined type marked with the DataContractAttribute
item.ElementExtensions.Add(new DataContractExtension() { Key = "X", Value = 4 });
// XmlSerializerExtension is a user-defined type that defines a ToString() method
item.ElementExtensions.Add(new XmlSerializerExtension() { Key = "Y", Value = 8 }, new XmlSerializer(typeof(XmlSerializerExtension)));
item.ElementExtensions.Add(new XElement("xElementExtension", new XElement("Key", new XAttribute("attr1", "someValue"), "Z"),
new XElement("Value", new XAttribute("attr1", "someValue"), "15")).CreateReader());
Dim item As New SyndicationItem()
' Add several different types of element extensions
item.ElementExtensions.Add("simpleString", "", "hello, world!")
item.ElementExtensions.Add("simpleString", "", "another simple string")
' DataContractExtension is a user-defined type marked with the DataContractAttribute
item.ElementExtensions.Add(New DataContractExtension With {.Key = "X", .Value = 4})
' XmlSerializerExtension is a user-defined type that defines a ToString() method
item.ElementExtensions.Add(New XmlSerializerExtension With {.Key = "Y", .Value = 8}, New XmlSerializer(GetType(XmlSerializerExtension)))
item.ElementExtensions.Add(New XElement("xElementExtension", New XElement("Key", New XAttribute("attr1", "someValue"), "Z"), _
New XElement("Value", New XAttribute("attr1", "someValue"), "15")).CreateReader())
Kommentarer
Elementtillägg är giltiga XML-element som inte anges i varken Atom 1.0- eller RSS 2.0-specifikationerna. Alla giltiga XML-element kan läggas till som ett tillägg, förutsatt att dess namnområde skiljer sig från det omslutande namnområdet. När de serialiseras skrivs tillägg som andra XML-element.
<mg:MyElement xmlns:mg="http://myserver/elements" />
Ett fullständigt exempel som visar hur du lägger till elementtillägg finns i exemplet Loosely-Typed Tillägg .