private static async Task ShrinkNormalAsync(Siaqodb siaqodb) { var allOrderByPos = (await(from RawdataInfo ri in siaqodb where ri.IsFree == false select ri).ToListAsync()).OrderBy(a => a.Position).ToList(); ISqoFile file = siaqodb.GetRawFile(); MemoryStream memStream = new MemoryStream(); MemoryStream memStreamNew = new MemoryStream(); byte[] fullFile = new byte[file.Length]; await file.ReadAsync(0, fullFile); memStream.Write(fullFile, 0, fullFile.Length); for (int i = 0; i < allOrderByPos.Count; i++) { RawdataInfo rawi = allOrderByPos[i]; byte[] actualBytes = new byte[rawi.Length]; memStream.Seek(rawi.Position, SeekOrigin.Begin); memStream.Read(actualBytes, 0, actualBytes.Length); if (i == 0) { rawi.Position = 0; memStreamNew.Write(actualBytes, 0, actualBytes.Length); } else { RawdataInfo prev = allOrderByPos[i - 1]; rawi.Position = prev.Position + prev.Length; memStreamNew.Seek(rawi.Position, SeekOrigin.Begin); memStreamNew.Write(actualBytes, 0, actualBytes.Length); } } for (int i = 0; i < allOrderByPos.Count; i++) { await siaqodb.StoreObjectAsync(allOrderByPos[i]); } file.Length = memStreamNew.Length; await file.WriteAsync(0, memStreamNew.ToArray()); }
public async Task SerializeTypeAsync(SqoTypeInfo ti) { await file.WriteAsync(0, SerializeTypeToBuffer(ti)).ConfigureAwait(false); }
public async Task <int> SaveTransactionalObjectAsync(byte[] objBytes, long pos) { await file.WriteAsync(pos, objBytes).ConfigureAwait(false); return(objBytes.Length); }