Class BinaryMemoryStream
A MemoryStream implementation whose primary purpose is to be used to create Binary objects.
Inherited Members
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public sealed class BinaryMemoryStream : MemoryStream, IAsyncDisposable, IDisposable
Constructors
BinaryMemoryStream()
Initializes a new instance of the BinaryMemoryStream with an expandable capacity initialized to zero.
Declaration
public BinaryMemoryStream()
BinaryMemoryStream(int)
Initializes a new instance of the BinaryMemoryStream with an expandable capacity initialized as specified.
Declaration
public BinaryMemoryStream(int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | capacity | The initial size of the internal array in bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Capacity is negative. |
Properties
CanWrite
Gets a value indicating whether the current stream supports writing.
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
bool | true if the stream supports writing; otherwise, false. |
Overrides
Methods
GetBuffer()
Returns the array of unsigned bytes from which this stream was created.
Declaration
public override byte[] GetBuffer()
Returns
Type | Description |
---|---|
byte[] | The byte array from which this stream was created. |
Overrides
Exceptions
Type | Condition |
---|---|
UnauthorizedAccessException | Buffer is not publicly visible. |
SetLength(long)
Sets the length of the current stream to the specified value.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
long | value | The value at which to set the length. |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | The current stream is not resizable and value is larger than the current capacity or the current stream does not support writing. |
ArgumentOutOfRangeException | Value is negative or is greater than the maximum length of the stream, where the maximum length is (System.Int32.MaxValue - origin), and origin is the index into the underlying buffer at which the stream starts. |
ToBinary()
Returns a new Binary object that holds the complete contents of this stream.
Declaration
public Binary ToBinary()
Returns
Type | Description |
---|---|
Binary | The contents of this stream as a Binary object. |
Write(byte[], int, int)
Writes a block of bytes to the current stream using data read from buffer.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The buffer to write data from. |
int | offset | The byte offset in buffer at which to begin writing from. |
int | count | The maximum number of bytes to write. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Buffer is |
NotSupportedException | The stream does not support writing or the current position is closer than count bytes to the end of the stream, and the capacity cannot be modified. |
ArgumentException | Offset subtracted from the buffer length is less than count. |
ArgumentOutOfRangeException | Offset or count are negative. |
IOException | An I/O error occurs. |
ObjectDisposedException | The current stream instance is closed. |
WriteByte(byte)
Writes a byte to the current stream at the current position.
Declaration
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | The byte to write. |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | The stream does not support writing or the current position is at the end of the stream, and the capacity cannot be modified. |
ObjectDisposedException | The current stream is closed. |