WrappingStreamBase class
A Stream that wraps another stream. One major feature of this class is that it does not dispose the underlying stream when it is disposed if None is used; this is useful when using classes such as BinaryReader that take ownership of the stream passed to their constructors. This class delegates a minimal number of properties and methods to the wrapped stream so that inheritors can override this class as they would Stream, e.g. override Read and get correct behavior for ReadAsync and CopyToAsync.
public abstract class WrappingStreamBase : Stream
Public Members
name |
description |
override CanRead { get; } |
Gets a value indicating whether the current stream supports reading. |
override CanSeek { get; } |
Gets a value indicating whether the current stream supports seeking. |
override CanTimeout { get; } |
Gets a value that determines whether the current stream can time out. |
override CanWrite { get; } |
Gets a value indicating whether the current stream supports writing. |
override Length { get; } |
Gets the length in bytes of the stream. |
override Position { get; set; } |
Gets or sets the position within the current stream. |
override ReadTimeout { get; set; } |
Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. |
override WriteTimeout { get; set; } |
Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. |
Close() |
Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. Instead of calling this method, ensure that the stream is properly disposed. |
override Flush() |
Clears all buffers for this stream and causes any buffered data to be written to the underlying device. |
abstract ReadAsync(…) |
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. |
override Seek(…) |
Sets the position within the current stream. |
override SetLength(…) |
Sets the length of the current stream. |
abstract WriteAsync(…) |
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. |
Protected Members
name |
description |
WrappingStreamBase(…) |
Initializes a new instance of the WrappingStreamBase class. |
WrappedStream { get; } |
Gets the wrapped stream. |
override Dispose(…) |
Disposes or releases the wrapped stream, based on the value of the Ownership parameter passed to the constructor. |
ThrowIfDisposed() |
Throws an ObjectDisposedException if this object has been disposed. |
See Also