Class DynamicDataSerializer

Serializes and Deserializes Dynamic Data Store objects. The serialized format is XML.

Inheritance
System.Object
DynamicDataSerializer
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Data.Serialization
Assembly: EPiServer.Data.dll
Version: 8.11.0
Syntax
public class DynamicDataSerializer

Constructors

DynamicDataSerializer()

Initializes a new instance of the DynamicDataSerializer class.

Declaration
public DynamicDataSerializer()
Remarks

Default constructor sets exceptionHandler to null, meaning exceptions will be thrown from serializer.

DynamicDataSerializer(Action<Exception>)

Initializes a new instance of the DynamicDataSerializer class.

Declaration
public DynamicDataSerializer(Action<Exception> exceptionHandler)
Parameters
Type Name Description
System.Action<System.Exception> exceptionHandler

The exception handler that will be called when an exception occurs.

Properties

IdMap

If the ids should be remapped during deserialization then a map of new identities should be passed in. This is e.g. the case when running mirroring to same site.

Declaration
public IDictionary<Guid, Guid> IdMap { get; set; }
Property Value
Type Description
System.Collections.Generic.IDictionary<System.Guid, System.Guid>

The id map.

Methods

Deserialize(IEnumerable<XElement>)

Deserializes the specified objects element and saves them to Dynamic Data Store

Declaration
public virtual void Deserialize(IEnumerable<XElement> objectsElement)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> objectsElement

The object elements to deserialize

Serialize(Identity, String)

Serializes the dynamic data store item with given identity in given store.

Declaration
public virtual IEnumerable<XElement> Serialize(Identity identity, string storeName)
Parameters
Type Name Description
Identity identity

The identity.

System.String storeName

Name of the store.

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>

A collection of serialized items

Remarks

If specified object references other objects, those will also be serialized. Meaning the whole object graph is serialized.

Serialize(IEnumerable<IdentityStoreMap>)

Serializes the dynamic data store items with given identity/storename.

Declaration
public virtual IEnumerable<XElement> Serialize(IEnumerable<IdentityStoreMap> identities)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<IdentityStoreMap> identities

The identities including storename of the items to serialize

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>

A collection of serialized items

Remarks

It specified objects references other objects, those will also be serialized. Meaning whole object graphs are serialized.

Events

DeserializedObject

Occurs when a DDS object is deserialized but not yet saved to DDS. An eventhandler has possibility to alter object or cancel save operation.

Declaration
public event EventHandler<SerializationEventArgs> DeserializedObject
Event Type
Type Description
System.EventHandler<SerializationEventArgs>

DeserializingFromXml

Occurs at deserilalization for items that has been modified by event SerializingToXml.

Declaration
public event EventHandler<DeserializingItemEventArgs> DeserializingFromXml
Event Type
Type Description
System.EventHandler<DeserializingItemEventArgs>

SerializingObject

Occurs when a DDS object is to be serialized. An eventhandler has possibility to alter object or cancel save operation.

Declaration
public event EventHandler<SerializationEventArgs> SerializingObject
Event Type
Type Description
System.EventHandler<SerializationEventArgs>

SerializingToXml

Occurs when a DDS object or a object reference has been serialized. An eventhandler has possibility to replace the serialized format of the object. If an item is modified then an eventhandler to DeserializingFromXml must be registered to handle recreation of object.

Declaration
public event EventHandler<SerializingItemEventArgs> SerializingToXml
Event Type
Type Description
System.EventHandler<SerializingItemEventArgs>

Extension Methods