예제 #1
0
        private void BackupForRestart(byte[] buffer, int offset, int count, int fileOffset, bool force)
        {
            InternalDebug.Assert(restartConsumer != null);

            if (!force && fileOffset > restartMax)
            {
                restartConsumer.DisableRestart();
                restartConsumer = null;

                preamble = null;
                return;
            }

            if (restartCache == null)
            {
                restartCache = new ByteCache();
            }

            byte[] cacheBuffer;
            int    cacheOffset;

            restartCache.GetBuffer(count, out cacheBuffer, out cacheOffset);

            Buffer.BlockCopy(buffer, offset, cacheBuffer, cacheOffset, count);

            restartCache.Commit(count);
        }
예제 #2
0
        public bool RestartWithNewEncoding(Encoding newEncoding)
        {
            if (this.encoding.CodePage == newEncoding.CodePage)
            {
                if (this.restartConsumer != null)
                {
                    this.restartConsumer.DisableRestart();
                    this.restartConsumer = null;

                    if (this.restartCache != null)
                    {
                        this.restartCache.Reset();
                        this.restartCache = null;
                    }
                }

                return(false);
            }

            if (this.restartConsumer == null || !this.restartConsumer.CanRestart())
            {
                return(false);
            }

            this.restartConsumer.Restart();

            this.SetNewEncoding(newEncoding);

            this.encodingChanged = true;

            if (this.readEnd != 0 && this.readFileOffset != 0)
            {
                this.BackupForRestart(this.readBuffer, 0, this.readEnd, this.readFileOffset, true);

                this.readEnd = 0;

                this.readFileOffset = 0;
            }
            else
            {
            }

            this.readCurrent   = 0;
            this.pushChunkUsed = 0;

            this.restartConsumer = null;

            this.parseStart = this.parseEnd = 0;

            this.restarting = this.restartCache != null && this.restartCache.Length != 0;

            return(true);
        }
        protected override void Dispose()
        {
            if (this.cache != null && this.cache is IDisposable)
            {
                ((IDisposable)this.cache).Dispose();
            }

            this.cache       = null;
            this.pushSink    = null;
            this.pullSink    = null;
            this.lineBuffer  = null;
            this.encoding    = null;
            this.encoder     = null;
            this.codePageMap = null;

            base.Dispose();
        }
예제 #4
0
        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();
        }
예제 #5
0
        protected override void Dispose()
        {
            if (this.restartCache != null && this.restartCache is IDisposable)
            {
                ((IDisposable)this.restartCache).Dispose();
            }

            this.restartCache    = null;
            this.pullSource      = null;
            this.pushSource      = null;
            this.parseBuffer     = null;
            this.readBuffer      = null;
            this.pushChunkBuffer = null;
            this.preamble        = null;
            this.restartConsumer = null;

            base.Dispose();
        }
예제 #6
0
        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();
        }