public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
{
if (this.isCustomSerialization)
{
object result = Activator.CreateInstance(this.type);
byte[] contents;
if (m_IsCompress)
{
contents = reader.ReadElementContentAsBinHex();
}
else
{
switch (m_ContentType)
{
case SerializeContentTypes.BinHex:
contents = reader.ReadElementContentAsBinHex();
break;
case SerializeContentTypes.String:
contents = Encoding.UTF8.GetBytes(reader.ReadElementContentAsString());
break;
default:
contents = Encoding.UTF8.GetBytes(reader.ReadElementContentAsString());
break;
}
}
using (MemoryStream ms = new MemoryStream(contents))
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(this.type);
if (m_IsCompress)
{
using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress))
{
result = ser.ReadObject(ds);
ds.Close();
}
}
else
{
result = ser.ReadObject(ms);
}
ms.Close();
ser = null;
return result;
}
}
else
{
return this.fallbackSerializer.ReadObject(reader, verifyObjectName);
}
}