Click or drag to resize

BlockStream Class

Implements an in-memory stream based on a collection of Block buffers rather than a single byte buffer. This is more efficient than MemoryStream for large streams and also avoids allocations in the large object heap.
Inheritance Hierarchy

Namespace:  Neon.IO
Assembly:  Neon.Common (in Neon.Common.dll) Version: 2.4.1
Syntax
public sealed class BlockStream : Stream

The BlockStream type exposes the following members.

Constructors
  NameDescription
Public methodBlockStream
Constructs a zero length stream with default block size.
Public methodBlockStream(Byte)
Constructs a stream from a byte array.
Public methodBlockStream(Int32)
Constructs a stream of the specified size using the default block size.
Public methodBlockStream(Block)
Constructs a stream from the blocks passed.
Public methodBlockStream(BlockArray)
Constructs a stream from the blocks passed.
Public methodBlockStream(Int32, Int32)
Constructs a stream of the specified size using the specified block size.
Public methodBlockStream(Int32, Int32, Int32)
Constructs a stream of the specified size using the specified block size and offset.
Top
Properties
  NameDescription
Public propertyCanRead
Returns true if the stream supports read operations.
(Overrides StreamCanRead.)
Public propertyCanSeek
Returns true if the stream supports seek operations.
(Overrides StreamCanSeek.)
Public propertyCanTimeout
Gets a value that determines whether the current stream can time out.
(Inherited from Stream.)
Public propertyCanWrite
Returns true if the stream supports write operations.
(Overrides StreamCanWrite.)
Public propertyLength
Returns the current size of the stream in bytes.
(Overrides StreamLength.)
Public propertyPosition
The current stream position.
(Overrides StreamPosition.)
Public propertyRawBlockArray
Returns the underlying block array without modification.
Public propertyReadTimeout
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.
(Inherited from Stream.)
Public propertyWriteTimeout
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out.
(Inherited from Stream.)
Top
Methods
  NameDescription
Public methodAppend(Block)
Appends a block to the end of the underlying BlockArray.
Public methodAppend(BlockArray)
Appends a block array to the end of the underlying BlockArray.
Public methodBeginRead (Inherited from Stream.)
Public methodBeginWrite (Inherited from Stream.)
Public methodClose
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.
(Inherited from Stream.)
Public methodCopyTo(Stream)
Reads the bytes from the current stream and writes them to another stream.
(Inherited from Stream.)
Public methodCopyTo(Stream, Int32)
Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
(Inherited from Stream.)
Public methodCopyToAsync(Stream)
Asynchronously reads the bytes from the current stream and writes them to another stream.
(Inherited from Stream.)
Public methodCopyToAsync(Stream, Int32)
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
(Inherited from Stream.)
Public methodCopyToAsync(Stream, Int32, CancellationToken)
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.
(Inherited from Stream.)
Public methodDispose
Releases all resources used by the Stream.
(Inherited from Stream.)
Public methodEndRead (Inherited from Stream.)
Public methodEndWrite (Inherited from Stream.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodFlush
Flushes any stream buffers.
(Overrides StreamFlush.)
Public methodFlushAsync
Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.
(Inherited from Stream.)
Public methodFlushAsync(CancellationToken)
Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.
(Inherited from Stream.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodRead
Reads bytes from the current stream position, advancing the position past the data read.
(Overrides StreamRead(Byte, Int32, Int32).)
Public methodReadAsync(Byte, Int32, Int32)
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
(Inherited from Stream.)
Public methodReadAsync(Byte, Int32, Int32, CancellationToken)
Asynchronously reads from the stream.
(Overrides StreamReadAsync(Byte, Int32, Int32, CancellationToken).)
Public methodReadBlocks
Returns requested bytes from the underlying block array as as a new block array.
Public methodReadByte
Reads a byte from the current stream position, advancing the position by 1.
(Overrides StreamReadByte.)
Public methodSeek
Moves the current stream position relative to the specified origin.
(Overrides StreamSeek(Int64, SeekOrigin).)
Public methodSetLength(Int64)
Sets the length of the stream.
(Overrides StreamSetLength(Int64).)
Public methodSetLength(Int64, Boolean)
Sets the length of the stream.
Public methodToArray
Assembles a contiguous a byte array from the underlying buffer array.
Public methodToBlocks
Returns the underlying buffer array.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWrite
Writes bytes to the stream at the current position, advancing the position past the data written.
(Overrides StreamWrite(Byte, Int32, Int32).)
Public methodWriteAsync(Byte, Int32, Int32)
Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
(Inherited from Stream.)
Public methodWriteAsync(Byte, Int32, Int32, CancellationToken)
Asynchronously writes bytes to the stream at the current position, advancing the position past the data written.
(Overrides StreamWriteAsync(Byte, Int32, Int32, CancellationToken).)
Public methodWriteByte
Writes a byte to the current stream position, advancing the position by 1.
(Overrides StreamWriteByte(Byte).)
Top
Extension Methods
  NameDescription
Public Extension MethodDeflateTo
Uses deflate to compress a source to a target stream.
(Defined by IOExtensions.)
Public Extension MethodGunzipTo
Uses GZIP to decompress a source to a target stream.
(Defined by IOExtensions.)
Public Extension MethodGzipTo
Uses GZIP to compress a source to a target stream.
(Defined by IOExtensions.)
Public Extension MethodInflateTo
Uses deflate to decompress a source to a target stream.
(Defined by IOExtensions.)
Public Extension MethodReadBytes
Reads the byte array from the current position, advancing the position past the value read.
(Defined by IOExtensions.)
Public Extension MethodReadToEnd
Reads all bytes from the current position to the end of the stream.
(Defined by IOExtensions.)
Public Extension MethodReadToEndAsync
Asynchronously reads all bytes from the current position to the end of the stream.
(Defined by IOExtensions.)
Public Extension MethodWrite
Writes a byte array to a stream.
(Defined by IOExtensions.)
Public Extension MethodWriteAsync
Asynchronously writes a byte array to a stream.
(Defined by IOExtensions.)
Top
Remarks
Note Note
Buffer array streams cannot be greater than or equal to 2GiB in length.
See Also