Table of Contents

Class WrapperStream

Namespace
Amazon.Runtime.Internal.Util
Assembly
AWSSDK.Core.dll

A wrapper stream.

public class WrapperStream : Stream, IDisposable, IAsyncDisposable
Inheritance
WrapperStream
Implements
Derived
Inherited Members

Constructors

WrapperStream(Stream)

Initializes WrapperStream with a base stream.

public WrapperStream(Stream baseStream)

Parameters

baseStream Stream

Properties

BaseStream

Base stream.

protected Stream BaseStream { get; }

Property Value

Stream

CanRead

Gets a value indicating whether the current stream supports reading. True if the stream supports reading; otherwise, false.

public override bool CanRead { get; }

Property Value

bool

CanSeek

Gets a value indicating whether the current stream supports seeking. True if the stream supports seeking; otherwise, false.

public override bool CanSeek { get; }

Property Value

bool

CanWrite

Gets a value indicating whether the current stream supports writing. True if the stream supports writing; otherwise, false.

public override bool CanWrite { get; }

Property Value

bool

Length

Gets the length in bytes of the stream.

public override long Length { get; }

Property Value

long

Position

Gets or sets the position within the current stream.

public override long Position { get; set; }

Property Value

long

ReadTimeout

Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.

public override int ReadTimeout { get; set; }

Property Value

int

WriteTimeout

Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out.

public override int WriteTimeout { get; set; }

Property Value

int

Methods

Dispose(bool)

Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.

protected override void Dispose(bool disposing)

Parameters

disposing bool

Flush()

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

public override void Flush()

FlushAsync(CancellationToken)

Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.

public override Task FlushAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.

Returns

Task

A task that represents the asynchronous flush operation.

GetNonWrapperBaseStream()

Returns the first base non-WrapperStream.

public Stream GetNonWrapperBaseStream()

Returns

Stream

First base stream that is non-WrapperStream.

GetNonWrapperBaseStream(Stream)

Returns the first base non-WrapperStream.

public static Stream GetNonWrapperBaseStream(Stream stream)

Parameters

stream Stream

Potential WrapperStream

Returns

Stream

Base non-WrapperStream.

GetSeekableBaseStream()

Returns the first base non-WrapperStream.

public Stream GetSeekableBaseStream()

Returns

Stream

First base stream that is non-WrapperStream.

Read(byte[], int, int)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

public override int Read(byte[] buffer, int offset, int count)

Parameters

buffer byte[]

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

offset int

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

count int

The maximum number of bytes to be read from the current stream.

Returns

int

The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

ReadAsync(byte[], int, int, CancellationToken)

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)

Parameters

buffer byte[]

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

offset int

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

count int

The maximum number of bytes to be read from the current stream.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.

Returns

Task<int>

A task that represents the asynchronous read operation. The value of the TResult parameter contains the total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

SearchWrappedStream(Func<Stream, bool>)

public Stream SearchWrappedStream(Func<Stream, bool> condition)

Parameters

condition Func<Stream, bool>

Returns

Stream

SearchWrappedStream(Stream, Func<Stream, bool>)

public static Stream SearchWrappedStream(Stream stream, Func<Stream, bool> condition)

Parameters

stream Stream
condition Func<Stream, bool>

Returns

Stream

Seek(long, SeekOrigin)

Sets the position within the current stream.

public override long Seek(long offset, SeekOrigin origin)

Parameters

offset long

A byte offset relative to the origin parameter.

origin SeekOrigin

A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.

Returns

long

The new position within the current stream.

SetLength(long)

Sets the length of the current stream.

public override void SetLength(long value)

Parameters

value long

The desired length of the current stream in bytes.

Write(byte[], int, int)

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

public override void Write(byte[] buffer, int offset, int count)

Parameters

buffer byte[]

An array of bytes. This method copies count bytes from buffer to the current stream.

offset int

The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

count int

The number of bytes to be written to the current stream.

WriteAsync(byte[], int, int, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)

Parameters

buffer byte[]

An array of bytes. This method copies count bytes from buffer to the current stream.

offset int

The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

count int

The number of bytes to be written to the current stream.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.

Returns

Task

A task that represents the asynchronous write operation.