Serialization events

Serialization events can be subscribed to so that Serialization exceptions don't occur. Subscribing to the events can be usefull for generating serialization reports that contain all errors that occurred during serialization or deserialization.

Subscribing to serialization events

Subscribing to serialization events can be done as follows:

 

            var serializer = new DatarecordSerializer<SomeRecordType>();
serializer.DatarecordOverflow += delegate(object sender, DatarecordOverflowEventArgs e)
{
// Write some logic here
};
serializer.DatarecordIncomplete += delegate(object sender, DatarecordIncompleteEventArgs e)
{
// Write some logic here
};
serializer.DatafieldEmpty += delegate(object sender, DatafieldEmptyEventArgs e)
{
// Write some logic here
};
serializer.DatafieldOverflow += delegate(object sender, DatafieldOverflowEventArgs e)
{
// Write some logic here
};

var result = serializer.Deserialize(stringRepresentationOfADatarecord);

Last edited Feb 15, 2011 at 6:35 PM by Coilz, version 2

Comments

No comments yet.