public static void WriteObject(this Stream stream, object value, Type valueType, ValueSerializer valueSerializer, bool preserveObjectReferences, SerializerSession session) { if (value == null) //value is null { NullSerializer.Instance.WriteManifest(stream, null, session); } else { int existingId; if (preserveObjectReferences && session.TryGetObjectId(value, out existingId)) { //write the serializer manifest ObjectReferenceSerializer.Instance.WriteManifest(stream, null, session); //write the object reference id ObjectReferenceSerializer.Instance.WriteValue(stream, existingId, session); } else { var vType = value.GetType(); var s2 = valueSerializer; if (vType != valueType) { //value is of subtype, lookup the serializer for that type s2 = session.Serializer.GetSerializerByType(vType); } //lookup serializer for subtype s2.WriteManifest(stream, vType, session); s2.WriteValue(stream, value, session); } } }
public ToSurrogateSerializer(Func<object, object> translator, Type type, ValueSerializer surrogateSerializer) { _type = type; _translator = translator; _surrogateSerializer = surrogateSerializer; }
public FromSurrogateSerializer(Func <object, object> translator, ValueSerializer surrogateSerializer) { _translator = translator; _surrogateSerializer = surrogateSerializer; }
public ToSurrogateSerializer(Func <object, object> translator, Type type, ValueSerializer surrogateSerializer) { _type = type; _translator = translator; _surrogateSerializer = surrogateSerializer; }
public FromSurrogateSerializer(Func<object, object> translator, ValueSerializer surrogateSerializer) { _translator = translator; _surrogateSerializer = surrogateSerializer; }