Class ReportXmlSerializer
Serializes and deserializes objects into and from XML. This class is dedicated for serializing and deserializing objects only from the Telerik.Reporting namespace.
Inheritance
Namespace: Telerik.Reporting.XmlSerialization
Assembly: Telerik.Reporting.dll
Syntax
public class ReportXmlSerializer : IXmlSerializer
Constructors
ReportXmlSerializer()
Initializes a new instance of the ReportXmlSerializer class.
Declaration
public ReportXmlSerializer()
Methods
Deserialize(Stream)
Deserializes the XML document contained by the specified System.IO.Stream.
Declaration
public object Deserialize(Stream stream)
Parameters
System.IO.Stream
stream
The System.IO.Stream that contains the XML document to deserialize. |
Returns
System.Object
The Telerik.Reporting object being deserialized. |
Remarks
Use the stream parameter to specify an object that derives from the System.IO.Stream class, which is designed to write to streams. Classes that derive from the System.IO.Stream class include: System.IO.BufferedStream, System.IO.FileStream, System.IO.MemoryStream, etc.
Examples
The following example deserializes an object using a System.IO.Stream:
using (System.IO.FileStream fileStream = new System.IO.FileStream("Report1.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(fileStream);
}
Using fileStream As New System.IO.FileStream("Report1.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
Dim report As Telerik.Reporting.Report = DirectCast(xmlSerializer.Deserialize(fileStream), Telerik.Reporting.Report)
End Using
Deserialize(TextReader)
Deserializes the XML document contained by the specified System.IO.TextReader.
Declaration
public object Deserialize(TextReader reader)
Parameters
System.IO.TextReader
reader
The System.IO.TextReader that contains the XML document to deserialize. |
Returns
System.Object
The Telerik.Reporting object being deserialized. |
Remarks
Classes that inherit from System.IO.TextReader include System.IO.StringReader and System.IO.StreamReader. If you are using a System.IO.StreamReader to deserialize an object, you must construct the System.IO.StreamReader with an appropriate System.Text.Encoding. The encoding specified by the XML document is ignored.
Examples
The following example deserializes an object using a System.IO.TextReader:
using (System.IO.FileStream fileStream = new System.IO.FileStream("Report1.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read))
using (System.IO.TextReader textReader = new System.IO.StreamReader(fileStream))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(textReader);
}
Using fileStream As New System.IO.FileStream("Report1.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read)
Using textReader As System.IO.TextReader = New System.IO.StreamReader(fileStream)
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
Dim report As Telerik.Reporting.Report = DirectCast(xmlSerializer.Deserialize(textReader), Telerik.Reporting.Report)
End Using
End Using
Deserialize(String)
Deserializes the XML document from the specified URI.
Declaration
public object Deserialize(string inputUri)
Parameters
System.String
inputUri
The URI for the file containing the XML data. |
Returns
System.Object
The Telerik.Reporting object being deserialized. |
Examples
The following example deserializes an object using a URI:
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize("Report1.xml");
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
Dim report As Telerik.Reporting.Report = DirectCast(xmlSerializer.Deserialize("Report1.xml"), Telerik.Reporting.Report)
Deserialize(XmlReader)
Deserializes the XML document contained by the specified System.Xml.XmlReader.
Declaration
public object Deserialize(XmlReader reader)
Parameters
System.Xml.XmlReader
reader
The System.Xml.XmlReader that contains the XML document to deserialize. |
Returns
System.Object
The Telerik.Reporting object being deserialized. |
Examples
The following example deserializes an object using a System.Xml.XmlReader:
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
settings.IgnoreWhitespace = true;
using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create("Report1.xml", settings))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(xmlReader);
}
Dim settings As New XmlReaderSettings()
settings.IgnoreWhitespace = True
Using xmlReader As System.Xml.XmlReader = System.Xml.XmlReader.Create("Report1.xml", settings)
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
Dim report As Telerik.Reporting.Report = DirectCast(xmlSerializer.Deserialize(xmlReader), Telerik.Reporting.Report)
End Using
Serialize(Stream, Object)
Serializes the specified value and writes the XML document to the specified System.IO.Stream.
Declaration
public void Serialize(Stream stream, object value)
Parameters
System.IO.Stream
stream
The System.IO.Stream used to write the XML document. |
System.Object
value
The value to serialize. |
Remarks
Use the stream parameter to specify an object that derives from the abstract System.IO.Stream class. Classes that derive from the System.IO.Stream class include: System.IO.BufferedStream, System.IO.FileStream, System.IO.MemoryStream, etc.
Examples
The following examples serializes an object using a System.IO.Stream:
using (System.IO.Stream stream = new System.IO.FileStream("Report.xml", System.IO.FileMode.Create))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
xmlSerializer.Serialize(stream, report);
}
Using stream As System.IO.Stream = New System.IO.FileStream("Report.xml", System.IO.FileMode.Create)
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
xmlSerializer.Serialize(stream, report)
End Using
Serialize(TextWriter, Object)
Serializes the specified value and writes the XML document to the specified System.IO.TextWriter.
Declaration
public void Serialize(TextWriter writer, object value)
Parameters
System.IO.TextWriter
writer
The System.IO.TextWriter used to write the XML document. |
System.Object
value
The value to serialize. |
Remarks
In the textWriter parameter, specify an object that derives from the abstract System.IO.TextWriter class. Classes that derive from the System.IO.TextWriter class include: System.IO.StreamWriter, System.IO.StringWriter, etc.
Examples
The following examples serializes an object using a System.IO.TextWriter:
using (System.IO.FileStream fs = new System.IO.FileStream("Report.xml", FileMode.Create))
using (System.IO.TextWriter writer = new System.IO.StreamWriter(fs, System.Text.Encoding.UTF8))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
xmlSerializer.Serialize(writer, report);
}
Using fs As New System.IO.FileStream("Report.xml", System.IO.FileMode.Create)
Using writer As System.IO.TextWriter = New System.IO.StreamWriter(fs, System.Text.Encoding.UTF8)
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
xmlSerializer.Serialize(writer, report)
End Using
End Using
Serialize(String, Object)
Serializes the specified value and writes the XML document to a file with the specified file name.
Declaration
public void Serialize(string fileName, object value)
Parameters
System.String
fileName
The file which you want to write to. The ReportXmlSerializer creates a file at the specified path and writes to it in XML 1.0 text syntax. The fileName must be a file system path. |
System.Object
value
The value to serialize. |
Examples
The following example serializes an object using a file path:
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
xmlSerializer.Serialize("Report.xml", report);
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
xmlSerializer.Serialize("Report.xml", report)
Serialize(XmlWriter, Object)
Serializes the specified value and writes the XML document to the specified System.Xml.XmlWriter.
Declaration
public void Serialize(XmlWriter writer, object value)
Parameters
System.Xml.XmlWriter
writer
The System.Xml.XmlWriter used to write the XML document. |
System.Object
value
The value to serialize. |
Remarks
In the xmlWriter parameter, specify an object that derives from the abstract System.Xml.XmlWriter class. For example you can use the System.Xml.XmlTextWriter class.
Examples
The following example serializes an object using a System.Xml.XmlWriter:
using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create("SerializedReport.xml"))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
xmlSerializer.Serialize(xmlWriter, report);
}
Using xmlWriter As System.Xml.XmlWriter = System.Xml.XmlWriter.Create("SerializedReport.xml")
Dim xmlSerializer As New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
xmlSerializer.Serialize(xmlWriter, report)
End Using