コード例 #1
0
        public StreamPipeWriter(Stream writingStream, StreamPipeWriterOptions options)
        {
            InnerStream = writingStream ?? throw new ArgumentNullException(nameof(writingStream));

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _minimumBufferSize = options.MinimumBufferSize;
            _pool = options.Pool == MemoryPool <byte> .Shared ? null : options.Pool;
            _bufferSegmentPool = new BufferSegmentStack(InitialSegmentPoolSize);
        }
コード例 #2
0
        public StreamPipeWriter(Stream writingStream, StreamPipeWriterOptions options)
        {
            if (writingStream is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.writingStream);
            }
            if (options is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.options);
            }

            InnerStream        = writingStream;
            _minimumBufferSize = options.MinimumBufferSize;
            _pool = options.Pool == MemoryPool <byte> .Shared ? null : options.Pool;
            _maxPooledBufferSize = _pool?.MaxBufferSize ?? -1;
            _bufferSegmentPool   = new BufferSegmentStack(InitialSegmentPoolSize);
            _leaveOpen           = options.LeaveOpen;
        }
コード例 #3
0
ファイル: PipeWriter.cs プロジェクト: shandan1/CollectionRef
 /// <summary>
 /// Creates a <see cref="PipeWriter"/> wrapping the specified <see cref="Stream"/>.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="writerOptions">The options.</param>
 /// <returns>A <see cref="PipeWriter"/> that wraps the <see cref="Stream"/>.</returns>
 public static PipeWriter Create(Stream stream, StreamPipeWriterOptions writerOptions = null)
 {
     return(new StreamPipeWriter(stream, writerOptions ?? StreamPipeWriterOptions.s_default));
 }