private void AllocNextChunk(int minimumChunkSize) { int length; if ((int)this.currentChunk.Length <= 0x3fffffff) { length = (int)this.currentChunk.Length * 2; } else { length = 0x7fffffff; } if (minimumChunkSize > length) { length = minimumChunkSize; } byte[] numArray = this.bufferManager.TakeBuffer(length); if (this.chunkCount == (int)this.chunks.Length) { byte[][] numArray1 = new byte[(int)this.chunks.Length * 2][]; Array.Copy(this.chunks, numArray1, (int)this.chunks.Length); this.chunks = numArray1; } BufferedOutputStream bufferedOutputStream = this; int num = bufferedOutputStream.chunkCount; int num1 = num; bufferedOutputStream.chunkCount = num + 1; this.chunks[num1] = numArray; this.currentChunk = numArray; this.currentChunkSize = 0; }
public XmlBuffer(int maxBufferSize) { if (maxBufferSize < 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxBufferSize", maxBufferSize, SR.ValueMustBeNonNegative)); int initialBufferSize = Math.Min(512, maxBufferSize); _stream = new BufferManagerOutputStream(SR.XmlBufferQuotaExceeded, initialBufferSize, maxBufferSize, BufferManager.CreateBufferManager(0, int.MaxValue)); _sections = new List<Section>(1); }
public XmlBuffer(int maxBufferSize) { if (maxBufferSize < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxBufferSize", maxBufferSize, System.ServiceModel.SR.GetString("ValueMustBeNonNegative"))); } int initialSize = Math.Min(0x200, maxBufferSize); this.stream = new BufferManagerOutputStream("XmlBufferQuotaExceeded", initialSize, maxBufferSize, BufferManager.CreateBufferManager(0L, 0x7fffffff)); this.sections = new List<Section>(1); }
public void Close() { int num; if (this.bufferState != BufferState.Created) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.CreateInvalidStateException()); } this.bufferState = BufferState.Reading; this.buffer = this.stream.ToArray(out num); this.writer = null; this.stream = null; }
private void WriteCore(byte[] buffer, int offset, int size) { if (size >= 0) { if (0x7fffffff - size >= this.totalSize) { int num = this.totalSize + size; if (num <= this.maxSize) { int length = (int)this.currentChunk.Length - this.currentChunkSize; if (size > length) { if (length > 0) { if (buffer != null) { Buffer.BlockCopy(buffer, offset, this.currentChunk, this.currentChunkSize, length); } this.currentChunkSize = (int)this.currentChunk.Length; offset = offset + length; size = size - length; } this.AllocNextChunk(size); } if (buffer != null) { Buffer.BlockCopy(buffer, offset, this.currentChunk, this.currentChunkSize, size); } this.totalSize = num; BufferedOutputStream bufferedOutputStream = this; bufferedOutputStream.currentChunkSize = bufferedOutputStream.currentChunkSize + size; return; } else { throw Fx.Exception.AsError(this.CreateQuotaExceededException(this.maxSizeQuota)); } } else { throw Fx.Exception.AsError(this.CreateQuotaExceededException(this.maxSizeQuota)); } } else { throw Fx.Exception.ArgumentOutOfRange("size", size, InternalSR.ValueMustBeNonNegative); } }
public override void WriteByte(byte value) { if (this.totalSize != this.maxSize) { if (this.currentChunkSize == (int)this.currentChunk.Length) { this.AllocNextChunk(1); } BufferedOutputStream bufferedOutputStream = this; int num = bufferedOutputStream.currentChunkSize; int num1 = num; bufferedOutputStream.currentChunkSize = num + 1; this.currentChunk[num1] = value; return; } else { throw Fx.Exception.AsError(this.CreateQuotaExceededException(this.maxSize)); } }
public void Close() { if (_bufferState != BufferState.Created) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateInvalidStateException()); _bufferState = BufferState.Reading; int bufferSize; _buffer = _stream.ToArray(out bufferSize); _writer = null; _stream = null; }