private void BackupForRestart(byte[] buffer, int offset, int count, int fileOffset, bool force) { if (!force && fileOffset > restartMax) { restartConsumer.DisableRestart(); restartConsumer = null; preamble = null; return; } if (restartCache == null) { restartCache = new ByteCache(); } byte[] dst; int dstOffset; restartCache.GetBuffer(count, out dst, out dstOffset); Buffer.BlockCopy(buffer, offset, dst, dstOffset, count); restartCache.Commit(count); }
private void EncodeBuffer(char[] buffer, int offset, int count, bool flush) { int maxByteCount = encoding.GetMaxByteCount(count); byte[] array = null; int num = 0; int num2 = 0; bool flag = true; byte[] array2; int num3; if (canRestart || pullSink == null || cache.Length != 0) { cache.GetBuffer(maxByteCount, out array2, out num3); } else { pullSink.GetOutputBuffer(out array, out num, out num2); if (num2 >= maxByteCount) { array2 = array; num3 = num; flag = false; } else { cache.GetBuffer(maxByteCount, out array2, out num3); } } int num4 = encoder.GetBytes(buffer, offset, count, array2, num3, flush); if (flag) { cache.Commit(num4); if (pullSink == null) { if (canRestart) { if (!restartablePushSink) { return; } } while (cache.Length != 0) { int count2; cache.GetData(out array2, out num3, out count2); pushSink.Write(array2, num3, count2); cache.ReportRead(count2); } return; } if (!canRestart) { num4 = cache.Read(array, num, num2); pullSink.ReportOutput(num4); return; } } else { pullSink.ReportOutput(num4); } }