public static SerializedObject FromMultiArray(MultiArray <byte> multiArrayData) { if (multiArrayData.IsEmpty) { return(null); } return(FromStream(multiArrayData.AsReadOnlyStream())); }
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 MultiArray <byte> Compress(MultiArray <byte> source) { var msDes = _recMemStream.New(); using (var msOrg = source.AsReadOnlyStream()) Compress(msOrg, msDes); var value = msDes.GetMultiArray(); msDes.Reset(); _recMemStream.Store(msDes); return(value); }
public async Task <MultiArray <byte> > DecompressAsync(MultiArray <byte> source) { var msDes = _recMemStream.New(); using (var msOrg = source.AsReadOnlyStream()) await DecompressAsync(msOrg, msDes).ConfigureAwait(false); var value = msDes.GetMultiArray(); msDes.Reset(); _recMemStream.Store(msDes); return(value); }
public object Deserialize(MultiArray <byte> value, Type valueType) { using (var stream = value.AsReadOnlyStream()) { if (Compressor is null) { return(OnDeserialize(stream, valueType)); } var ms = _recMemStream.New(); Compressor.Decompress(stream, ms); ms.Position = 0; var objValue = OnDeserialize(ms, valueType); ms.Reset(); _recMemStream.Store(ms); return(objValue); } }