31.10.2014 Views

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorials | 25<br />

Below an example of how an overrided ReportData property could look like (example taken from the Blog class):<br />

using StarCommunity.Core.Modules.Reporting;<br />

...<br />

publicoverrideIReportData ReportData<br />

{<br />

get<br />

{<br />

//Init xml document<br />

XmlDocument xmlDoc = newXmlDocument();<br />

XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-<br />

8", "yes");<br />

XmlElement rootNode = xmlDoc.CreateElement("ReportedContent");<br />

xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement);<br />

xmlDoc.AppendChild(rootNode);<br />

//Add presentation text element<br />

XmlElement textElement = xmlDoc.CreateElement("Text");<br />

textElement.AppendChild(xmlDoc.CreateTextNode<br />

(this.PresentationText));<br />

rootNode.AppendChild(textElement);<br />

//Add presentation image if any<br />

if (this.PresentationImage != null)<br />

{<br />

XmlElement imageElement = xmlDoc.CreateElement("Image");<br />

imageElement.SetAttribute("ID",<br />

this.PresentationImage.ID.ToString());<br />

rootNode.AppendChild(imageElement);<br />

}<br />

returnnew<br />

StarCommunity.Core.Modules.Reporting.ReportData(this.Name,<br />

xmlDoc.OuterXml, this.Created, this.Author);<br />

}<br />

}<br />

© <strong>EPiServer</strong> AB

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!