Class Block
Used to reference a block in a BlockArray or BlockStream.
Namespace: Neon.Common
Assembly: Neon.Common.dll
Syntax
public sealed class Block
Constructors
Block(byte[])
Constructs a block.
Declaration
public Block(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The byte buffer. |
Block(byte[], int, int)
Constructs a block.
Declaration
public Block(byte[] buffer, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | buffer | The byte buffer. |
int | offset | Offset of the first referenced byte. |
int | length | Byte length of the reference. |
Block(int)
Allocates a block to a newly allocated buffer of the specified size.
Declaration
public Block(int size)
Parameters
Type | Name | Description |
---|---|---|
int | size | The new block size in bytes. |
Properties
Buffer
The referenced buffer.
Declaration
public byte[] Buffer { get; set; }
Property Value
Type | Description |
---|---|
byte[] |
this[int]
Accesses the byte at the specified index in the block.
Declaration
public byte this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index |
Property Value
Type | Description |
---|---|
byte |
Length
The number of referenced bytes.
Declaration
public int Length { get; set; }
Property Value
Type | Description |
---|---|
int |
Offset
The offset of the starting position of the referenced bytes in the buffer.
Declaration
public int Offset { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
Assemble(params Block[])
Assembles the bytes referenced by the blocks into a contiguous buffer.
Declaration
public static byte[] Assemble(params Block[] blocks)
Parameters
Type | Name | Description |
---|---|---|
Block[] | blocks | The blocks. |
Returns
Type | Description |
---|---|
byte[] | A contiguous buffer. |
CopyFrom(byte[], int, int, int)
Copies bytes from the byte array passed into the block.
Declaration
public void CopyFrom(byte[] source, int sourceOffset, int targetOffset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | source | The source byte array. |
int | sourceOffset | Offset of the first byte to copy from the source array. |
int | targetOffset | Logical offset of the first target byte in the block. |
int | length | Number of bytes to copy. |
CopyTo(int, byte[], int, int)
Copies bytes from the logical offset in the block to the target byte array.
Declaration
public void CopyTo(int sourceOffset, byte[] target, int targetOffset, int length)
Parameters
Type | Name | Description |
---|---|---|
int | sourceOffset | Logical offset of the first byte to copy. |
byte[] | target | The output byte array. |
int | targetOffset | Target offset where the first byte is to be written. |
int | length | The number of bytes to copy. |
SetRange(int, int)
Modifies the range of bytes referenced by the instance.
Declaration
public void SetRange(int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
int | offset | Index of the first referenced byte. |
int | length | Number of bytes referenced. |
Operators
explicit operator ArraySegment<byte>(Block)
Explict cast from a Block to a byte ArraySegment<T>
Declaration
public static explicit operator ArraySegment<byte>(Block block)
Parameters
Type | Name | Description |
---|---|---|
Block | block | The Block to be converted. |
Returns
Type | Description |
---|---|
ArraySegment<byte> | The equivalent ArraySegment<T>. |
explicit operator Block(ArraySegment<byte>)
Explict cast from a byte ArraySegment<T> to a Block.
Declaration
public static explicit operator Block(ArraySegment<byte> segment)
Parameters
Type | Name | Description |
---|---|---|
ArraySegment<byte> | segment | The array segment to be converted. |
Returns
Type | Description |
---|---|
Block | The equivalent Block. |