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); }
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; }
/// <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)); }