public void DeserializeOnAppDomain(byte[] data, Settings settings) { var stream = new MemoryStream(data); var deserializer = new Serializer(settings); obj = deserializer.Deserialize<object>(stream); }
/// <summary> /// Initializes a new instance of the <see cref="Antmicro.Migrant.Customization.Settings"/> class. /// </summary> /// <param name='serializationMethod'> /// Method used for serialization. /// </param> /// <param name='deserializationMethod'> /// Method used for deserialization. /// </param> /// <param name='versionTolerance'> /// Specifies the possible level of difference between class layout when it was serialized and in the /// moment of deserialization. /// </param> /// <param name = "treatCollectionAsUserObject"> /// Specifies if collection objects are to be deserialized without optimization (treated as normal user objects). /// </param> /// <param name = "supportForISerializable"> /// Specifies whether Migrant should use GetObjectData approach for serialization. /// </param> /// <param name="useBuffering"> /// True if buffering should be used, false if writes should directly go to the stream and reads should never read /// data in advance. Disabling buffering also disables padding. /// </param> /// <param name="disableTypeStamping"> /// Specifies if type stamping should be disabled in order to improve performance and limit output stream size. /// </param> /// <param name="referencePreservation"> /// Tells serializer how to treat references between sessions of open stream serialization. /// </param> public Settings With(Method serializationMethod = Method.Generated, Method deserializationMethod = Method.Generated, VersionToleranceLevel versionTolerance = 0, bool supportForISerializable = false, bool treatCollectionAsUserObject = false, bool useBuffering = true, bool disableTypeStamping = false, ReferencePreservation referencePreservation = ReferencePreservation.Preserve) { var result = new Settings { SerializationMethod = serializationMethod, DeserializationMethod = deserializationMethod, VersionTolerance = versionTolerance, SupportForISerializable = supportForISerializable, TreatCollectionAsUserObject = treatCollectionAsUserObject, UseBuffering = useBuffering, DisableTypeStamping = disableTypeStamping, ReferencePreservation = referencePreservation }; return result; }
public OpenStreamSerializationTests(bool useGeneratedSerializer, bool useGeneratedDeserializer) { settings = new Settings(useGeneratedSerializer ? Method.Generated : Method.Reflection, useGeneratedDeserializer ? Method.Generated : Method.Reflection); }
/// <summary> /// Initializes a new instance of the <see cref="Antmicro.Migrant.Customization.Settings"/> class. /// </summary> /// <param name='serializationMethod'> /// Method used for serialization. /// </param> /// <param name='deserializationMethod'> /// Method used for deserialization. /// </param> /// <param name='versionTolerance'> /// Specifies the possible level of difference between class layout when it was serialized and in the /// moment of deserialization. /// </param> /// <param name = "treatCollectionAsUserObject"> /// Specifies if collection objects are to be deserialized without optimization (treated as normal user objects). /// </param> /// <param name = "supportForISerializable"> /// Specifies whether Migrant should use GetObjectData approach for serialization. /// </param> /// <param name="useBuffering"> /// True if buffering should be used, false if writes should directly go to the stream and reads should never read /// data in advance. Disabling buffering also disables padding. /// </param> /// <param name="disableTypeStamping"> /// Specifies if type stamping should be disabled in order to improve performance and limit output stream size. /// </param> /// <param name="referencePreservation"> /// Tells serializer how to treat references between sessions of open stream serialization. /// </param> public Settings With(Method? serializationMethod = null, Method? deserializationMethod = null, VersionToleranceLevel? versionTolerance = null, bool? supportForISerializable = null, bool? treatCollectionAsUserObject = null, bool? useBuffering = null, bool? disableTypeStamping = null, ReferencePreservation? referencePreservation = null) { var result = new Settings { SerializationMethod = serializationMethod ?? SerializationMethod, DeserializationMethod = deserializationMethod ?? DeserializationMethod, VersionTolerance = versionTolerance ?? VersionTolerance, SupportForISerializable = supportForISerializable ?? SupportForISerializable, TreatCollectionAsUserObject = treatCollectionAsUserObject ?? TreatCollectionAsUserObject, UseBuffering = useBuffering ?? UseBuffering, DisableTypeStamping = disableTypeStamping ?? DisableTypeStamping, ReferencePreservation = referencePreservation ?? ReferencePreservation }; return result; }