public override T Deserialize <T>(Stream stream) { var tools = _tools; if (tools is null) { tools = new SerTools(); _tools = tools; } if (Compressor is null) { if (typeof(T) == typeof(GenericObject)) { return((T)tools.Deserializer.GenericObjectDeserialize(stream)); } return((T)tools.Deserializer.Deserialize(stream)); } tools.ComStream.Reset(); Compressor.Decompress(stream, tools.ComStream); tools.ComStream.Position = 0; if (typeof(T) == typeof(GenericObject)) { return((T)tools.Deserializer.GenericObjectDeserialize(tools.ComStream)); } return((T)tools.Deserializer.Deserialize(tools.ComStream)); }
protected override void OnSerialize(Stream stream, object item, Type itemType) { var tools = _tools; if (tools is null) { tools = new SerTools(); _tools = tools; } tools.Serializer.Serialize(stream, item, itemType); }
protected override object OnDeserialize(Stream stream, Type itemType) { var tools = _tools; if (tools is null) { tools = new SerTools(); _tools = tools; } if (itemType == typeof(GenericObject)) { return(tools.Deserializer.GenericObjectDeserialize(stream)); } return(tools.Deserializer.Deserialize(stream)); }
public override void Serialize <T>(T item, Stream stream) { var tools = _tools; if (tools is null) { tools = new SerTools(); _tools = tools; } if (Compressor is null) { tools.Serializer.Serialize(stream, item); return; } tools.SerStream.Reset(); tools.Serializer.Serialize(tools.SerStream, item); tools.SerStream.Position = 0; Compressor.Compress(tools.SerStream, stream); }
public override T Deserialize <T>(MultiArray <byte> value) { var tools = _tools; if (tools is null) { tools = new SerTools(); _tools = tools; } if (Compressor is null) { using (var stream = value.AsReadOnlyStream()) return((T)tools.Deserializer.Deserialize(stream)); } tools.ComStream.Reset(); using (var stream = value.AsReadOnlyStream()) Compressor.Decompress(stream, tools.ComStream); tools.ComStream.Position = 0; return((T)tools.Deserializer.Deserialize(tools.ComStream)); }
public override MultiArray <byte> Serialize <T>(T item) { var tools = _tools; if (tools is null) { tools = new SerTools(); _tools = tools; } else { tools.SerStream.Reset(); } if (Compressor is null) { tools.Serializer.Serialize(tools.SerStream, item); return(tools.SerStream.GetMultiArray()); } tools.ComStream.Reset(); tools.Serializer.Serialize(tools.SerStream, item); tools.SerStream.Position = 0; Compressor.Compress(tools.SerStream, tools.ComStream); return(tools.ComStream.GetMultiArray()); }