C# Class Appccelerate.IO.Streams.StreamDecoratorStream

Abstract decorator class for a Stream

This class is used to implement stream decorator classes. For creating a new stream decorator derive a new class from this one and override the methods that you want to decorate. All methods that are not overwritten are passed to the decorated stream.

All methods throw a NoStreamException when no stream is assigned to this class at the time a method is called.

Inheritance: Stream
Show file Open project: appccelerate/appccelerate

Public Methods

Method Description
BeginRead ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult

Begins an asynchronous read operation.

BeginWrite ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult

Begins an asynchronous write operation.

Close ( ) : void

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

EndRead ( IAsyncResult asyncResult ) : int

Waits for the pending asynchronous read to complete.

EndWrite ( IAsyncResult asyncResult ) : void

Ends an asynchronous write operation.

Flush ( ) : void

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Read ( byte buffer, int offset, int count ) : int

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

ReadByte ( ) : int
Seek ( long offset, SeekOrigin origin ) : long

When overridden in a derived class, sets the position within the current stream.

SetLength ( long value ) : void

When overridden in a derived class, sets the length of the current stream.

ToString ( ) : string

Returns a that represents the current .

Write ( byte buffer, int offset, int count ) : void

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteByte ( byte value ) : void

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Protected Methods

Method Description
SetStream ( Stream stream ) : void

Sets the stream that shall be decorated.

StreamDecoratorStream ( Stream decoratedStream ) : System

Initializes a new instance of the StreamDecoratorStream class.

ThrowNoStreamException ( ) : void

Derived classes can override this method to handle cases where a method is called while the decorated device is not assigned.

Private Methods

Method Description
AssertStreamNotNull ( ) : void

Asserts the stream is not null.

Method Details

BeginRead() public method

Begins an asynchronous read operation.
Attempted an asynchronous read past the end of the stream, or a disk error /// occurs. The current Stream implementation does not support the read /// operation. One or more of the arguments is invalid. Methods were called after the stream was closed. Thrown when no stream is assigned as decorated stream. ///
public BeginRead ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult
buffer byte The buffer to read the data into.
offset int The byte offset in buffer at which to begin writing data read from the stream.
count int The maximum number of bytes to read.
callback AsyncCallback An optional asynchronous callback, to be called when the read is complete.
state object A user-provided object that distinguishes this particular asynchronous read request /// from other requests.
return IAsyncResult

BeginWrite() public method

Begins an asynchronous write operation.
The current Stream implementation does not support the write /// operation. Attempted an asynchronous write past the end of the stream, /// or a disk error occurs. One or more of the arguments is invalid. Methods were called after the stream was closed.
public BeginWrite ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult
buffer byte The buffer to write data from.
offset int The byte offset in buffer from which to begin writing.
count int The maximum number of bytes to write.
callback AsyncCallback An optional asynchronous callback, to be called when the write is complete.
state object A user-provided object that distinguishes this particular asynchronous write request /// from other requests.
return IAsyncResult

Close() public method

Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
Thrown when no stream is assigned as decorated stream. ///
public Close ( ) : void
return void

EndRead() public method

Waits for the pending asynchronous read to complete.
asyncResult did not originate from a /// /// method on the current stream. asyncResult is null. Thrown when no stream is assigned as decorated stream. ///
public EndRead ( IAsyncResult asyncResult ) : int
asyncResult IAsyncResult The reference to the pending asynchronous request to finish.
return int

EndWrite() public method

Ends an asynchronous write operation.
asyncResult is null. asyncResult did not originate from a /// /// method on the current stream. Thrown when no stream is assigned as decorated stream. ///
public EndWrite ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult A reference to the outstanding asynchronous I/O request.
return void

Flush() public method

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
An I/O error occurs. Thrown when no stream is assigned as decorated stream. ///
public Flush ( ) : void
return void

Read() public method

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
The sum of offset and count is larger than the buffer length. /// Methods were called after the stream was closed. The stream does not support reading. buffer is null. An I/O error occurs. offset or count is negative. Thrown when no stream is assigned as decorated stream. ///
public Read ( byte buffer, int offset, int count ) : int
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.
return int

ReadByte() public method

public ReadByte ( ) : int
return int

Seek() public method

When overridden in a derived class, sets the position within the current stream.
An I/O error occurs. The stream does not support seeking, such as if the stream /// is constructed from a pipe or console output. Methods were called after the stream was closed. /// Thrown when no stream is assigned as decorated stream. ///
public Seek ( long offset, SeekOrigin origin ) : long
offset long A byte offset relative to the origin parameter.
origin SeekOrigin A value of type indicating the reference /// point used to obtain the new position.
return long

SetLength() public method

When overridden in a derived class, sets the length of the current stream.
The stream does not support both writing and seeking, /// such as if the stream is constructed from a pipe or console output. An I/O error occurs. Methods were called after the stream was closed. Thrown when no stream is assigned as decorated stream. ///
public SetLength ( long value ) : void
value long The desired length of the current stream in bytes.
return void

SetStream() protected method

Sets the stream that shall be decorated.
protected SetStream ( Stream stream ) : void
stream Stream The stream that shall be decorated.
return void

StreamDecoratorStream() protected method

Initializes a new instance of the StreamDecoratorStream class.
protected StreamDecoratorStream ( Stream decoratedStream ) : System
decoratedStream Stream The decorated stream.
return System

ThrowNoStreamException() protected method

Derived classes can override this method to handle cases where a method is called while the decorated device is not assigned.
protected ThrowNoStreamException ( ) : void
return void

ToString() public method

Returns a that represents the current .
Thrown when no stream is assigned as decorated stream. ///
public ToString ( ) : string
return string

Write() public method

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
An I/O error occurs. The stream does not support writing. Methods were called after the stream was closed. buffer is null. The sum of offset and count is greater than the buffer length. /// offset or count is negative. Thrown when no stream is assigned as decorated stream. ///
public Write ( byte buffer, int offset, int count ) : void
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.
return void

WriteByte() public method

Writes a byte to the current position in the stream and advances the position within the stream by one byte.
An I/O error occurs. Methods were called after the stream was closed. The stream does not support writing, or the stream is already /// closed.
public WriteByte ( byte value ) : void
value byte The byte to write to the stream.
return void