public DotNetSerializableCodec( IFieldCodec <Type> typeCodec, IFieldCodec <string> stringCodec, IFieldCodec <object> objectCodec, IUntypedCodecProvider untypedCodecProvider) { this.typeCodec = typeCodec; this.untypedCodecProvider = untypedCodecProvider; var entrySerializer = new SerializationEntryCodec(stringCodec, objectCodec); var constructorFactory = new SerializationConstructorFactory(); var serializationCallbacks = new SerializationCallbacksFactory(); var formatterConverter = new FormatterConverter(); this.objectSerializer = new ObjectSerializer( entrySerializer, constructorFactory, serializationCallbacks, formatterConverter, this.streamingContext); this.valueTypeSerializerFactory = new ValueTypeSerializerFactory( entrySerializer, constructorFactory, serializationCallbacks, formatterConverter, this.streamingContext); }
public ListCodec(IFieldCodec <T> fieldCodec, IFieldCodec <int> intCodec, IUntypedCodecProvider codecProvider, ListActivator <T> activator) { this.fieldCodec = fieldCodec; this.intCodec = intCodec; this.codecProvider = codecProvider; this.activator = activator; }
public DictionaryCodec( IFieldCodec <KeyValuePair <TKey, TValue> > pairCodec, IUntypedCodecProvider codecProvider, IFieldCodec <IEqualityComparer <TKey> > comparerCodec, DictionaryActivator <TKey, TValue> activator) { this.pairCodec = pairCodec; this.codecProvider = codecProvider; this.comparerCodec = comparerCodec; this.activator = activator; }
public JsonCodec( IUntypedCodecProvider codecProvider, JsonSerializerSettings settings = null, Func <Type, bool> isSupportedFunc = null) { this.codecProvider = codecProvider; this.settings = settings ?? new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full }; this.isSupportedFunc = isSupportedFunc ?? (_ => true); }
private static object DeserializeFromMarker( Reader reader, SerializerSession session, Field field, IUntypedCodecProvider serializers, UnknownFieldMarker marker, uint reference, Type lastResortFieldType) { // Create a reader at the position specified by the marker. var referencedReader = new Reader(reader.GetBuffers()); referencedReader.Advance(marker.Offset); // Determine the correct type for the field. var fieldType = marker.Field.FieldType ?? field.FieldType ?? lastResortFieldType; // Get a serializer for that type. var specificSerializer = serializers.GetCodec(fieldType); // Reset the session's reference id so that the deserialized object overwrites the marker. var originalCurrentReferenceId = session.ReferencedObjects.CurrentReferenceId; session.ReferencedObjects.CurrentReferenceId = reference - 1; // Deserialize the object, replacing the marker in the session. try { return(specificSerializer.ReadValue(referencedReader, session, marker.Field)); } finally { // Revert the reference id. session.ReferencedObjects.CurrentReferenceId = originalCurrentReferenceId; } }
public AbstractTypeSerializer(IUntypedCodecProvider codecProvider) { this.codecProvider = codecProvider; }
public JsonCodec(IUntypedCodecProvider codecProvider) : this(codecProvider, null, null) { }
public ArrayCodec(IFieldCodec <T> fieldCodec, IFieldCodec <int> intCodec, IUntypedCodecProvider codecProvider) { this.fieldCodec = fieldCodec; this.intCodec = intCodec; this.codecProvider = codecProvider; }
public static object ReadReference(Reader reader, SerializerSession session, Field field, IUntypedCodecProvider serializers, Type expectedType) { var reference = reader.ReadVarUInt32(); if (!session.ReferencedObjects.TryGetReferencedObject(reference, out object value)) { ThrowReferenceNotFound(expectedType, reference); } switch (value) { case UnknownFieldMarker marker: return(DeserializeFromMarker(reader, session, field, serializers, marker, reference, expectedType)); default: return(value); } }
public static T ReadReference <T>(Reader reader, SerializerSession session, Field field, IUntypedCodecProvider serializers) { return((T)ReadReference(reader, session, field, serializers, typeof(T))); }
public ObjectCodec(IUntypedCodecProvider codecProvider) { this.codecProvider = codecProvider; }
public ConcreteTypeSerializer(IActivator <TField> activator, IUntypedCodecProvider codecProvider, IPartialSerializerProvider partialSerializerProvider) { this.activator = activator; this.codecProvider = codecProvider; this.serializer = partialSerializerProvider.GetPartialSerializer <TField>(); }
public TypeSerializerCodec(IUntypedCodecProvider codecProvider) { this.codecProvider = codecProvider; }
public StringCodec(IUntypedCodecProvider codecProvider) { this.codecProvider = codecProvider; }
public MultiDimensionalArrayCodec(IUntypedCodecProvider codecProvider, IFieldCodec <int[]> intArrayCodec, IFieldCodec <T> elementCodec) { this.codecProvider = codecProvider; this.intArrayCodec = intArrayCodec; this.elementCodec = elementCodec; }
public ByteArrayCodec(IUntypedCodecProvider codecProvider) { this.codecProvider = codecProvider; }