private void AllocNextChunk(int minimumChunkSize) { int num; num = ((int)this.currentChunk.Length <= 1073741823 ? (int)this.currentChunk.Length * 2 : 2147483647); if (minimumChunkSize > num) { num = minimumChunkSize; } byte[] numArray = this.bufferManager.TakeBuffer(num); 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; } byte[][] numArray2 = this.chunks; BufferedOutputStream bufferedOutputStream = this; int num1 = bufferedOutputStream.chunkCount; int num2 = num1; bufferedOutputStream.chunkCount = num1 + 1; numArray2[num2] = numArray; this.currentChunk = numArray; this.currentChunkSize = 0; }
public override void WriteByte(byte value) { if (this.totalSize == this.maxSize) { throw Fx.Exception.AsError(this.CreateQuotaExceededException(this.maxSize), null); } if (this.currentChunkSize == (int)this.currentChunk.Length) { this.AllocNextChunk(1); } byte[] numArray = this.currentChunk; BufferedOutputStream bufferedOutputStream = this; int num = bufferedOutputStream.currentChunkSize; int num1 = num; bufferedOutputStream.currentChunkSize = num + 1; numArray[num1] = value; }
private void WriteCore(byte[] buffer, int offset, int size) { if (size < 0) { throw Fx.Exception.ArgumentOutOfRange("size", size, SRClient.ValueMustBeNonNegative); } if (2147483647 - size < this.totalSize) { throw Fx.Exception.AsError(this.CreateQuotaExceededException(this.maxSizeQuota), null); } int num = this.totalSize + size; if (num > this.maxSize) { throw Fx.Exception.AsError(this.CreateQuotaExceededException(this.maxSizeQuota), null); } 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; }