Class NonClosingStreamWrapper
Wraps a stream for all operations except Close and Dispose, which merely flush the stream and prevent further operations from being carried out using this wrapper.
Inherited Members
Namespace: Acoustics.Shared
Assembly: Acoustics.Shared.dll
Syntax
public sealed class NonClosingStreamWrapper : Stream, IAsyncDisposable, IDisposable
Constructors
| Improve this Doc View SourceNonClosingStreamWrapper(Stream)
Initializes a new instance of the Non
Declaration
public NonClosingStreamWrapper(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to wrap. Must not be null. |
Exceptions
Type | Condition |
---|---|
Argument |
stream is null. |
Properties
| Improve this Doc View SourceBaseStream
Gets stream wrapped by this wrapper.
Declaration
public Stream BaseStream { get; }
Property Value
Type | Description |
---|---|
Stream |
CanRead
Gets a value indicating whether indicates whether or not the underlying stream can be read from.
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceCanSeek
Gets a value indicating whether indicates whether or not the underlying stream supports seeking.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceCanWrite
Gets a value indicating whether indicates whether or not the underlying stream can be written to.
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceLength
Gets returns the length of the underlying stream.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
Int64 |
Overrides
| Improve this Doc View SourcePosition
Gets or sets the current position in the underlying stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
Int64 |
Overrides
Methods
| Improve this Doc View SourceBeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
Begins an asynchronous read operation.
Declaration
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | The buffer to read the data into. |
Int32 | offset | The byte offset in buffer at which to begin writing data read from the stream. |
Int32 | count | The maximum number of bytes to read. |
Async |
callback | An optional asynchronous callback, to be called when the read is complete. |
Object | state | A user-provided object that distinguishes this particular asynchronous read request from other requests. |
Returns
Type | Description |
---|---|
IAsync |
An IAsyncResult that represents the asynchronous read, which could still be pending. |
Overrides
| Improve this Doc View SourceBeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)
Begins an asynchronous write operation.
Declaration
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | The buffer to write data from. |
Int32 | offset | The byte offset in buffer from which to begin writing. |
Int32 | count | The maximum number of bytes to write. |
Async |
callback | An optional asynchronous callback, to be called when the write is complete. |
Object | state | A user-provided object that distinguishes this particular asynchronous write request from other requests. |
Returns
Type | Description |
---|---|
IAsync |
An IAsyncResult that represents the asynchronous write, which could still be pending. |
Overrides
| Improve this Doc View SourceClose()
This method is not proxied to the underlying stream; instead, the wrapper is marked as unusable for other (non-close/Dispose) operations. The underlying stream is flushed if the wrapper wasn't closed before this call.
Declaration
public override void Close()
Overrides
| Improve this Doc View SourceEndRead(IAsyncResult)
Waits for the pending asynchronous read to complete.
Declaration
public override int EndRead(IAsyncResult asyncResult)
Parameters
Type | Name | Description |
---|---|---|
IAsync |
asyncResult | The reference to the pending asynchronous request to finish. |
Returns
Type | Description |
---|---|
Int32 | The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams only return zero (0) at the end of the stream, otherwise, they should block until at least one byte is available. |
Overrides
| Improve this Doc View SourceEndWrite(IAsyncResult)
Ends an asynchronous write operation.
Declaration
public override void EndWrite(IAsyncResult asyncResult)
Parameters
Type | Name | Description |
---|---|---|
IAsync |
asyncResult | A reference to the outstanding asynchronous I/O request. |
Overrides
| Improve this Doc View SourceFlush()
Flushes the underlying stream.
Declaration
public override void Flush()
Overrides
| Improve this Doc View SourceInitializeLifetimeService()
Throws a NotSupportedException.
Declaration
public override object InitializeLifetimeService()
Returns
Type | Description |
---|---|
Object | n/a. |
Overrides
| Improve this Doc View SourceRead(Byte[], Int32, Int32)
Reads a sequence of bytes from the underlying stream and advances the position within the stream by the number of bytes read.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | 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 underlying source. |
Int32 | offset | The zero-based byte offset in buffer at which to begin storing the data read from the underlying stream. |
Int32 | count | The maximum number of bytes to be read from the underlying stream. |
Returns
Type | Description |
---|---|
Int32 | 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. |
Overrides
| Improve this Doc View SourceReadByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Declaration
public override int ReadByte()
Returns
Type | Description |
---|---|
Int32 | The unsigned byte cast to an Int32, or -1 if at the end of the stream. |
Overrides
| Improve this Doc View SourceSeek(Int64, SeekOrigin)
Sets the position within the current stream.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
Int64 | offset | A byte offset relative to the origin parameter. |
Seek |
origin | A value of type SeekOrigin indicating the reference point used to obtain the new position. |
Returns
Type | Description |
---|---|
Int64 | The new position within the underlying stream. |
Overrides
| Improve this Doc View SourceSetLength(Int64)
Sets the length of the underlying stream.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
Int64 | value | The desired length of the underlying stream in bytes. |
Overrides
| Improve this Doc View SourceWrite(Byte[], Int32, Int32)
Writes a sequence of bytes to the underlying stream and advances the current position within the stream by the number of bytes written.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | An array of bytes. This method copies count bytes from buffer to the underlying stream. |
Int32 | offset | The zero-based byte offset in buffer at which to begin copying bytes to the underlying stream. |
Int32 | count | The number of bytes to be written to the underlying stream. |
Overrides
| Improve this Doc View SourceWriteByte(Byte)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Declaration
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
Byte | value | The byte to write to the stream. |