Helper class is used to copy the content of a source stream to a destination stream, with optimizations based on expected usage within HttpClient and with the ability to dispose of the source stream when the copy has completed.
コード例 #1
0
ファイル: StreamContent.cs プロジェクト: slamj1/runtime
 protected override void SerializeToStream(Stream stream, TransportContext?context, CancellationToken cancellationToken)
 {
     Debug.Assert(stream != null);
     PrepareContent();
     // If the stream can't be re-read, make sure that it gets disposed once it is consumed.
     StreamToStreamCopy.Copy(_content, stream, _bufferSize, !_content.CanSeek);
 }
コード例 #2
0
        protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
        {
            Debug.Assert(stream != null);

            PrepareContent();
            // If the stream can't be re-read, make sure that it gets disposed once it is consumed.
            return(StreamToStreamCopy.CopyAsync(_content, stream, _bufferSize, !_content.CanSeek));
        }
コード例 #3
0
ファイル: StreamContent.cs プロジェクト: johnhhm/corefx
        protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
        {
            Debug.Assert(stream != null);

            PrepareContent();
            // If the stream can't be re-read, make sure that it gets disposed once it is consumed.
            StreamToStreamCopy sc = new StreamToStreamCopy(_content, stream, _bufferSize, !_content.CanSeek);
            return sc.StartAsync();
        }
コード例 #4
0
ファイル: StreamContent.cs プロジェクト: nuxleus/WCFWeb
        protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
        {
            Contract.Assert(stream != null);

            PrepareContent();
            // If the stream can't be re-read, make sure that it gets disposed once it is consumed.
            StreamToStreamCopy sc = new StreamToStreamCopy(content, stream, bufferSize, !content.CanSeek);

            return(sc.StartAsync());
        }
コード例 #5
0
ファイル: StreamContent.cs プロジェクト: lateralusX/runtime
 private Task SerializeToStreamAsyncCore(Stream stream, CancellationToken cancellationToken)
 {
     Debug.Assert(stream != null);
     PrepareContent();
     return(StreamToStreamCopy.CopyAsync(
                _content,
                stream,
                _bufferSize,
                !_content.CanSeek, // If the stream can't be re-read, make sure that it gets disposed once it is consumed.
                cancellationToken));
 }
コード例 #6
0
 private Task SerializeToStreamAsyncCore(Stream stream, CancellationToken cancellationToken)
 {
     this.PrepareContent();
     return(StreamToStreamCopy.CopyAsync(this._content, stream, this._bufferSize, !this._content.CanSeek, cancellationToken));
 }