/// <inheritdoc/> public override void SetLength(long value) { if (value < 0 || value > int.MaxValue) { throw new ArgumentOutOfRangeException("value"); } ThrowIfDisposed(); EnsureWriteable(); _buffer.EnsureCapacity((int)value); _length = (int)value; if (_position > _length) { _position = _length; } }
private void PrepareToWrite(int count) { _byteBuffer.EnsureCapacity(_position + count); _byteBuffer.Length = _byteBuffer.Capacity; if (_length < _position) { _byteBuffer.Clear(_length, _position - _length); } }