In This Article

XmlSerializerBase<TObj, TXmlObj> Class

Provides the base class for an object that can serialize and deserialize a hierarchy of XmlObjectBase objects.

public abstract class XmlSerializerBase<TObj, TXmlObj> where TXmlObj : XmlObjectBase
Type Parameters:
TObj -

The Type of object that is represented by TXmlObj.

TXmlObj -

The Type of XmlObjectBase to serialize/deserialize.

Inheritance:
object object
Derived:
DockSiteLayoutSerializer NavigationBarLayoutSerializer

Constructors

XmlSerializerBase()

Initializes an instance of the XmlSerializerBase class.

protected XmlSerializerBase()

XmlSerializerBase(TXmlObj)

Initializes an instance of the XmlSerializerBase class.

protected XmlSerializerBase(TXmlObj rootNode)
Parameter Type Description
rootNode TXmlObj

The root TXmlObj node.

Properties

CustomTypes

Gets the collection of custom Types that can be serialized and deserialized using this serializer.

public IList<Type> CustomTypes { get; }

Property Value

IList<Type>:

The collection of custom Types that can be serialized and deserialized using this serializer.

Remarks

If the object graph contains any Type that is not registered with the serializer, an exception will occur during serialization and deserialization.
This collection allows for the registration of custom Types with the serializer.

RootNode

Gets or sets the root TXmlObj node that is serialized and deserialized.

public TXmlObj RootNode { get; set; }

Property Value

TXmlObj:

The root TXmlObj node that is serialized and deserialized.

Methods

ApplyTo(TObj)

Applies the information contained within this serializer to the specified object.

public abstract void ApplyTo(TObj obj)
Parameter Type Description
obj TObj

The object to update with deserialized information.

CreateRootNodeFor(TObj)

Creates a root node for the specified object.

public abstract TXmlObj CreateRootNodeFor(TObj obj)
Parameter Type Description
obj TObj

The object for which to create a root node.

Returns

TXmlObj:

The root node that was created.

GetXmlSerializer()

Returns the System.Xml.Serialization.XmlSerializer to use for serialization and deserialization.

protected abstract XmlSerializer GetXmlSerializer()

Returns

XmlSerializer:

The System.Xml.Serialization.XmlSerializer that was created.

LoadFromFile(string)

Deserializes the RootNode from the specified file.

public void LoadFromFile(string path)
Parameter Type Description
path string

The path to the file from which to read an object.

LoadFromFile(string, TObj)

Deserializes the RootNode from the specified file.

public void LoadFromFile(string path, TObj obj)
Parameter Type Description
path string

The path to the file from which to read an object.

obj TObj

The object to update with data.

LoadFromStream(Stream)

Deserializes the RootNode from the specified Stream.

public void LoadFromStream(Stream stream)
Parameter Type Description
stream Stream

The Stream from which to read an object.

LoadFromStream(Stream, TObj)

Deserializes the RootNode from the specified Stream.

public void LoadFromStream(Stream stream, TObj obj)
Parameter Type Description
stream Stream

The Stream from which to read an object.

obj TObj

The object to update with data.

LoadFromString(string)

Deserializes the RootNode from the specified XML string.

public void LoadFromString(string xml)
Parameter Type Description
xml string

The XML string from which to read an object.

LoadFromString(string, TObj)

Deserializes the RootNode from the specified XML string.

public void LoadFromString(string xml, TObj obj)
Parameter Type Description
xml string

The XML string from which to read an object.

obj TObj

The object to update with data.

LoadFromXmlReader(XmlReader)

Deserializes the RootNode from the specified System.Xml.XmlReader.

public void LoadFromXmlReader(XmlReader reader)
Parameter Type Description
reader XmlReader

The System.Xml.XmlReader from which to read an object.

LoadFromXmlReader(XmlReader, TObj)

Deserializes the RootNode from the specified System.Xml.XmlReader.

public void LoadFromXmlReader(XmlReader reader, TObj obj)
Parameter Type Description
reader XmlReader

The System.Xml.XmlReader from which to read an object.

obj TObj

The object to update with data.

RaiseObjectDeserialized(ItemSerializationEventArgs)

Raises the ObjectDeserialized event with the specified arguments.

protected virtual void RaiseObjectDeserialized(ItemSerializationEventArgs eventArgs)
Parameter Type Description
eventArgs ItemSerializationEventArgs

The ItemSerializationEventArgs instance containing the event data.

RaiseObjectSerialized(ItemSerializationEventArgs)

Raises the ObjectSerialized event with the specified arguments.

protected virtual void RaiseObjectSerialized(ItemSerializationEventArgs eventArgs)
Parameter Type Description
eventArgs ItemSerializationEventArgs

The ItemSerializationEventArgs instance containing the event data.

SaveToFile(string)

Serializes the RootNode to XML within a file.

public void SaveToFile(string path)
Parameter Type Description
path string

The path to the output file.

SaveToFile(string, TObj)

Serializes the RootNode to XML within a file.

public void SaveToFile(string path, TObj obj)
Parameter Type Description
path string

The path to the output file.

obj TObj

The object for which to serialize data.

SaveToStream(Stream)

Serializes the RootNode to XML within a Stream.

public void SaveToStream(Stream stream)
Parameter Type Description
stream Stream

The Stream to write to.

SaveToStream(Stream, TObj)

Serializes the RootNode to XML within a Stream.

public void SaveToStream(Stream stream, TObj obj)
Parameter Type Description
stream Stream

The Stream to write to.

obj TObj

The object for which to serialize data.

SaveToString()

Serializes the RootNode to an XML string.

public string SaveToString()

Returns

string:

The XML string that was created.

SaveToString(TObj)

Serializes the RootNode to an XML string.

public string SaveToString(TObj obj)
Parameter Type Description
obj TObj

The object for which to serialize data.

Returns

string:

The XML string that was created.

SaveToXmlWriter(XmlWriter)

Serializes the RootNode to XML by using an System.Xml.XmlWriter.

public void SaveToXmlWriter(XmlWriter writer)
Parameter Type Description
writer XmlWriter

The System.Xml.XmlWriter to write to.

SaveToXmlWriter(XmlWriter, TObj)

Serializes the RootNode to XML by using an System.Xml.XmlWriter.

public void SaveToXmlWriter(XmlWriter writer, TObj obj)
Parameter Type Description
writer XmlWriter

The System.Xml.XmlWriter to write to.

obj TObj

The object for which to serialize data.

WriteHeader(XmlWriter)

Allows for dynamic injection of an XML comment or other data before the main serialization routine occurs.

protected virtual void WriteHeader(XmlWriter writer)
Parameter Type Description
writer XmlWriter

The System.Xml.XmlWriter to write to.

Events

ObjectDeserialized

Occurs when an object is deserialized.

public event EventHandler<ItemSerializationEventArgs> ObjectDeserialized

Event Type

EventHandler<ItemSerializationEventArgs>

ObjectSerialized

Occurs when an object is serialized.

public event EventHandler<ItemSerializationEventArgs> ObjectSerialized

Event Type

EventHandler<ItemSerializationEventArgs>

Inherited Members