protected override void Dispose() { if (cache != null && cache is IDisposable) { ((IDisposable)cache).Dispose(); } cache = null; pushSink = null; pullSink = null; lineBuffer = null; encoding = null; encoder = null; codePageMap = null; base.Dispose(); }
protected override void Dispose() { if (restartCache != null && restartCache is IDisposable) { ((IDisposable)restartCache).Dispose(); } restartCache = null; pullSource = null; pushSource = null; parseBuffer = null; readBuffer = null; pushChunkBuffer = null; preamble = null; restartConsumer = null; base.Dispose(); }
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); }
public bool RestartWithNewEncoding(Encoding newEncoding) { if (encoding.CodePage == newEncoding.CodePage) { if (restartConsumer != null) { restartConsumer.DisableRestart(); restartConsumer = null; if (restartCache != null) { restartCache.Reset(); restartCache = null; } } return(false); } if (restartConsumer == null || !restartConsumer.CanRestart()) { return(false); } restartConsumer.Restart(); SetNewEncoding(newEncoding); encodingChanged = true; if (readEnd != 0 && readFileOffset != 0) { BackupForRestart(readBuffer, 0, readEnd, readFileOffset, true); readEnd = 0; readFileOffset = 0; } readCurrent = 0; pushChunkUsed = 0; restartConsumer = null; parseStart = (parseEnd = 0); restarting = (restartCache != null && restartCache.Length != 0); return(true); }