Joutsen v0.5.0+12-g5dd5f7e
Public Member Functions | Protected Member Functions | Properties | List of all members
Joutsen.IO.ReadOnlyStream Class Reference

A stream that provides only readonly funcionality. More...

Public Member Functions

 ReadOnlyStream (Stream stream)
 Creates a new readonly instance of a stream. More...
 
override void Flush ()
 Flushes what was written to the stream. More...
 
override int Read (byte[] buffer, int offset, int count)
 Reads a sequence of bytes from the stream into a buffer. More...
 
override long Seek (long offset, SeekOrigin origin)
 Changes the current position within the stream. More...
 
override void SetLength (long value)
 Changes the length of the stream. More...
 
override void Write (byte[] buffer, int offset, int count)
 Writes to the stream. More...
 
override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 Writes to the stream asynchronously. More...
 
override void EndWrite (IAsyncResult asyncResult)
 Ends writing to the stream asynchrounously. More...
 
override void WriteByte (byte value)
 Writes a single byte to the stream. More...
 
override Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken)
 Writes to the stream asynchronously. More...
 
override Task FlushAsync (CancellationToken cancellationToken)
 Flushes the write buffer of the stream. More...
 
override void Close ()
 Closes the stream preventing further use of it. More...
 

Protected Member Functions

override void Dispose (bool disposing)
 Disposes of resources used by the stream. More...
 
void CheckIfStreamIsClosed ()
 Checks if the stream is already closed. More...
 

Properties

override bool CanRead [get]
 Checks if the stream can be read. More...
 
override bool CanSeek [get]
 Checks if it is possible to seek in the stream or if it can only be read in sequence. More...
 
override bool CanWrite [get]
 Checks if the stream is writable. More...
 
override long Length [get]
 Checks the length of the stream. More...
 
override long Position [get, set]
 Checks or sets the current position in the stream. More...
 

Detailed Description

A stream that provides only readonly funcionality.

Since
0.5.0
Remarks
This class does not handle closing the underlying data stream.

Constructor & Destructor Documentation

◆ ReadOnlyStream()

Joutsen.IO.ReadOnlyStream.ReadOnlyStream ( Stream  stream)

Creates a new readonly instance of a stream.

Member Function Documentation

◆ BeginWrite()

override IAsyncResult Joutsen.IO.ReadOnlyStream.BeginWrite ( byte[]  buffer,
int  offset,
int  count,
AsyncCallback  callback,
object  state 
)

Writes to the stream asynchronously.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ CheckIfStreamIsClosed()

void Joutsen.IO.ReadOnlyStream.CheckIfStreamIsClosed ( )
protected

Checks if the stream is already closed.

Exceptions
IOExceptionif the stream is closed

◆ Close()

override void Joutsen.IO.ReadOnlyStream.Close ( )

Closes the stream preventing further use of it.

◆ Dispose()

override void Joutsen.IO.ReadOnlyStream.Dispose ( bool  disposing)
protected

Disposes of resources used by the stream.

This also closes the stream.

◆ EndWrite()

override void Joutsen.IO.ReadOnlyStream.EndWrite ( IAsyncResult  asyncResult)

Ends writing to the stream asynchrounously.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ Flush()

override void Joutsen.IO.ReadOnlyStream.Flush ( )

Flushes what was written to the stream.

This operation is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ FlushAsync()

override Task Joutsen.IO.ReadOnlyStream.FlushAsync ( CancellationToken  cancellationToken)

Flushes the write buffer of the stream.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ Read()

override int Joutsen.IO.ReadOnlyStream.Read ( byte[]  buffer,
int  offset,
int  count 
)

Reads a sequence of bytes from the stream into a buffer.

Parameters
bufferthe buffer
offsetthe start offset of the buffer
countthe maximum number of bytes to read
Returns
the actual number of bytes read
Exceptions
IOExceptionif the stream is closed

◆ Seek()

override long Joutsen.IO.ReadOnlyStream.Seek ( long  offset,
SeekOrigin  origin 
)

Changes the current position within the stream.

Parameters
offsetthe new position in the stream
originthe way to interpret the offset, from the beginning, end or current position
Returns
the new position
Exceptions
IOExceptionif the stream is closed

◆ SetLength()

override void Joutsen.IO.ReadOnlyStream.SetLength ( long  value)

Changes the length of the stream.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ Write()

override void Joutsen.IO.ReadOnlyStream.Write ( byte[]  buffer,
int  offset,
int  count 
)

Writes to the stream.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ WriteAsync()

override Task Joutsen.IO.ReadOnlyStream.WriteAsync ( byte[]  buffer,
int  offset,
int  count,
CancellationToken  cancellationToken 
)

Writes to the stream asynchronously.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

◆ WriteByte()

override void Joutsen.IO.ReadOnlyStream.WriteByte ( byte  value)

Writes a single byte to the stream.

This method is not supported.

Exceptions
NotSupportedExceptionwhenever the method is called

Property Documentation

◆ CanRead

override bool Joutsen.IO.ReadOnlyStream.CanRead
get

Checks if the stream can be read.

◆ CanSeek

override bool Joutsen.IO.ReadOnlyStream.CanSeek
get

Checks if it is possible to seek in the stream or if it can only be read in sequence.

◆ CanWrite

override bool Joutsen.IO.ReadOnlyStream.CanWrite
get

Checks if the stream is writable.

This is always fals.

◆ Length

override long Joutsen.IO.ReadOnlyStream.Length
get

Checks the length of the stream.

Exceptions
IOExceptionif the stream is closed

◆ Position

override long Joutsen.IO.ReadOnlyStream.Position
getset

Checks or sets the current position in the stream.

Exceptions
IOExceptionif the stream is closed