Ejemplo n.º 1
0
        /// <summary>Constructs a new <see cref="ByteBufferWriter"/> instance with a specified <paramref name="byteBuffer"/>.</summary>
        /// <param name="byteBuffer">An instance of <see cref="IByteBuffer" /> used as a destination for writing.</param>
        /// <exception cref="ArgumentNullException">Thrown when the instance of <see cref="IByteBuffer" /> that is passed in is null.</exception>
        public ByteBufferWriter(IByteBuffer byteBuffer)
        {
            if (byteBuffer is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.byteBuffer);
            }
            if (!byteBuffer.IsSingleIoBuffer)
            {
                ThrowHelper.ThrowNotSupportedException_UncompositeBuffer();
            }

            _output         = byteBuffer;
            _buffered       = 0;
            _bytesCommitted = 0;
            _buffer         = _output.FreeSpan;
        }