您可以编写一个适配器类,它在反序列化期间预处理您的序列化数据,并将所有其他函数连接到密封DataContractJsonSerializer
类。
public class DataContractSystemJsonSerializer : XmlObjectSerializer
{
protected DataContractJsonSerializer innerSerializer;
public DataContractSystemJsonSerializer(Type t)
{
this.innerSerializer = new DataContractJsonSerializer (t);
}
...
public override Object ReadObject(Stream stream)
{
Object obj = null;
MemoryStream out = new MemoryStream();
Byte[] buf = new Byte[64];
stream.Read(buf,0,64);
int i = 0;
while(stream.Read(buf,i,1))
{
convertDatesInBuffer(&buf, &i);
out.write(buf, i, 1);
i = (i+1)%64;
}
return innerSerializer.ReadObject(out);
}
}