public ConverterEncodingOutput(Stream destination, bool push, bool restartable, Encoding encoding, bool encodingSameAsInput, bool testBoundaryConditions, IResultsFeedback resultFeedback) { this.resultFeedback = resultFeedback; if (!push) { pullSink = (destination as ConverterStream); pullSink.SetSource(this); } else { pushSink = destination; if (restartable && destination.CanSeek && destination.Position == destination.Length) { restartablePushSink = true; restartPosition = destination.Position; } } canRestart = restartable; this.restartable = restartable; lineBuffer = new char[4096]; minCharsEncode = (testBoundaryConditions ? 1 : 256); this.encodingSameAsInput = encodingSameAsInput; originalEncoding = encoding; ChangeEncoding(encoding); if (this.resultFeedback != null) { this.resultFeedback.Set(ConfigParameter.OutputEncoding, this.encoding); } }
public ConverterDecodingInput(Stream source, bool push, Encoding encoding, bool detectEncodingFromByteOrderMark, int maxParseToken, int restartMax, int inputBufferSize, bool testBoundaryConditions, IResultsFeedback resultFeedback, IProgressMonitor progressMonitor) : base(progressMonitor) { this.resultFeedback = resultFeedback; this.restartMax = restartMax; if (push) { pushSource = (source as ConverterStream); } else { pullSource = source; } this.detectEncodingFromByteOrderMark = detectEncodingFromByteOrderMark; minDecodeBytes = (testBoundaryConditions ? 1 : 64); originalEncoding = encoding; SetNewEncoding(encoding); maxTokenSize = ((maxParseToken == 2147483647) ? maxParseToken : (testBoundaryConditions ? maxParseToken : ((maxParseToken + 1023) / 1024 * 1024))); parseBuffer = new char[testBoundaryConditions ? 55L : Math.Min(4096L, (long)maxTokenSize + (long)(minDecodeChars + 1))]; if (pushSource != null) { readBuffer = new byte[Math.Max(minDecodeBytes * 2, 8)]; return; } int num = Math.Max(CalculateMaxBytes(parseBuffer.Length), inputBufferSize); readBuffer = new byte[num]; }
public ConverterDecodingInput( Stream source, bool push, System.Text.Encoding encoding, bool detectEncodingFromByteOrderMark, int maxParseToken, int restartMax, int inputBufferSize, bool testBoundaryConditions, IResultsFeedback resultFeedback, IProgressMonitor progressMonitor) : base(progressMonitor) { this.resultFeedback = resultFeedback; this.restartMax = restartMax; if (push) { InternalDebug.Assert(source is ConverterStream); this.pushSource = source as ConverterStream; } else { InternalDebug.Assert(source.CanRead); this.pullSource = source; } this.detectEncodingFromByteOrderMark = detectEncodingFromByteOrderMark; this.minDecodeBytes = testBoundaryConditions ? 1 : 64; this.originalEncoding = encoding; this.SetNewEncoding(encoding); InternalDebug.Assert(this.minDecodeBytes == 1 || this.minDecodeBytes >= Math.Max(4, this.preamble.Length)); this.maxTokenSize = (maxParseToken == Int32.MaxValue) ? maxParseToken : testBoundaryConditions? maxParseToken: (maxParseToken + 1023) / 1024 * 1024; this.parseBuffer = new char[testBoundaryConditions ? 55 : Math.Min(4096, (long)this.maxTokenSize + (this.minDecodeChars + 1))]; if (this.pushSource != null) { this.readBuffer = new byte[Math.Max(this.minDecodeBytes * 2, 8)]; } else { int size = Math.Max(this.CalculateMaxBytes(this.parseBuffer.Length), inputBufferSize); this.readBuffer = new byte[size]; } }
public ConverterEncodingOutput( Stream destination, bool push, bool restartable, System.Text.Encoding encoding, bool encodingSameAsInput, bool testBoundaryConditions, IResultsFeedback resultFeedback) { this.resultFeedback = resultFeedback; if (!push) { this.pullSink = destination as ConverterStream; InternalDebug.Assert(this.pullSink != null); this.pullSink.SetSource(this); } else { InternalDebug.Assert(destination.CanWrite); this.pushSink = destination; if (restartable && destination.CanSeek && destination.Position == destination.Length) { this.restartablePushSink = true; this.restartPosition = destination.Position; } } this.restartable = this.canRestart = restartable; this.lineBuffer = new char[4096]; this.minCharsEncode = testBoundaryConditions ? 1 : 256; this.encodingSameAsInput = encodingSameAsInput; this.originalEncoding = encoding; this.ChangeEncoding(encoding); if (this.resultFeedback != null) { this.resultFeedback.Set(ConfigParameter.OutputEncoding, this.encoding); } }
public RtfDecompressConverter(Stream input, bool push, Stream output, bool disableFastLoop, IResultsFeedback resultFeedback, int inputBufferSize, int outputBufferSize) : base(input, push, output, inputBufferSize, outputBufferSize) { this.resultFeedback = resultFeedback; this.disableFastLoop = disableFastLoop; this.window = new byte[4130]; Buffer.BlockCopy(RtfCompressCommon.PreloadData, 0, this.window, 0, RtfCompressCommon.PreloadData.Length); this.windowCurrent = RtfCompressCommon.PreloadData.Length; Buffer.BlockCopy(RtfCompressCommon.PreloadData, 0, this.window, 4096, 34); }