C# Class OpenSyno.Services.ReadWriteMemoryStream

A memory stream with the ability to write data at the end of it while reading at an arbitrary position.
Only the Read and Write method were implemented. This stream can be typically used to start using the first chunks of data of a file before it is completely downloaded, when it is located on a slow link. Example : Start playing an mp3 file before it is completely downloaded.
Inheritance: System.IO.MemoryStream
Show file Open project: salfab/open-syno

Public Methods

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

Reads a block of bytes from the current stream and writes the data to buffer.

ReadWriteMemoryStream ( int size ) : System

Initializes a new instance of the ReadWriteMemoryStream class.

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

Writes a block of bytes to the current stream using data read from buffer.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Method Details

BeginRead() public method

public BeginRead ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult
buffer byte
offset int
count int
callback AsyncCallback
state object
return IAsyncResult

Close() public method

public Close ( ) : void
return void

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

Read() public method

Reads a block of bytes from the current stream and writes the data to buffer.
is null. or is negative. subtracted from the buffer length is less than . The current stream instance is closed.
public Read ( byte buffer, int offset, int count ) : int
buffer byte When this method returns, contains the specified byte array with the values between and ( + - 1) replaced by the characters read from the current stream.
offset int The byte offset in at which to begin reading.
count int The maximum number of bytes to read.
return int

ReadWriteMemoryStream() public method

Initializes a new instance of the ReadWriteMemoryStream class.
public ReadWriteMemoryStream ( int size ) : System
size int The size.
return System

Write() public method

Writes a block of bytes to the current stream using data read from buffer.
is null. The stream does not support writing. For additional information see .-or- The current position is closer than bytes to the end of the stream, and the capacity cannot be modified. subtracted from the buffer length is less than . or are negative. An I/O error occurs. The current stream instance is closed.
public Write ( byte buffer, int offset, int count ) : void
buffer byte The buffer to write data from.
offset int The byte offset in at which to begin writing from.
count int The maximum number of bytes to write.
return void