Class BinaryReaderWriter
- Namespace
- Alis.Core.Network.Internal
- Assembly
- Alis.dll
The binary reader writer class
internal class BinaryReaderWriter
Inheritance
Inherited Members
Methods
ConvertToLong(ArraySegment<byte>)
Converts the to long using the specified buffer
internal static long ConvertToLong(ArraySegment<byte> buffer)
Parameters
buffer
ArraySegment<byte>-
The buffer
Returns
- long
-
The long
GetBytesInCorrectEndianness(int, bool)
Gets the bytes in correct endianness using the specified value
internal static byte[] GetBytesInCorrectEndianness(int value, bool isLittleEndian)
Parameters
Returns
- byte[]
-
The buffer
HandleEndianness(bool, ArraySegment<byte>)
Handles the endianness using the specified is little endian
internal static void HandleEndianness(bool isLittleEndian, ArraySegment<byte> buffer)
Parameters
isLittleEndian
bool-
The is little endian
buffer
ArraySegment<byte>-
The buffer
ReadExactly(int, Stream, ArraySegment<byte>, CancellationToken)
Reads the exactly using the specified length
public static Task ReadExactly(int length, Stream stream, ArraySegment<byte> buffer, CancellationToken cancellationToken)
Parameters
length
int-
The length
stream
Stream-
The stream
buffer
ArraySegment<byte>-
The buffer
cancellationToken
CancellationToken-
The cancellation token
Returns
Exceptions
- EndOfStreamException
- InternalBufferOverflowException
-
Unable to read {length} bytes into buffer (offset: {buffer.Offset} size: {buffer.Count}). Use a larger read buffer
ReadLongExactly(Stream, bool, ArraySegment<byte>, CancellationToken)
Reads the long exactly using the specified stream
public static Task<long> ReadLongExactly(Stream stream, bool isLittleEndian, ArraySegment<byte> buffer, CancellationToken cancellationToken)
Parameters
stream
Stream-
The stream
isLittleEndian
bool-
The is little endian
buffer
ArraySegment<byte>-
The buffer
cancellationToken
CancellationToken-
The cancellation token
Returns
ReadULongExactly(Stream, bool, ArraySegment<byte>, CancellationToken)
Reads the u long exactly using the specified stream
public static Task<ulong> ReadULongExactly(Stream stream, bool isLittleEndian, ArraySegment<byte> buffer, CancellationToken cancellationToken)
Parameters
stream
Stream-
The stream
isLittleEndian
bool-
The is little endian
buffer
ArraySegment<byte>-
The buffer
cancellationToken
CancellationToken-
The cancellation token
Returns
ReadUShortExactly(Stream, bool, ArraySegment<byte>, CancellationToken)
Reads the u short exactly using the specified stream
public static Task<ushort> ReadUShortExactly(Stream stream, bool isLittleEndian, ArraySegment<byte> buffer, CancellationToken cancellationToken)
Parameters
stream
Stream-
The stream
isLittleEndian
bool-
The is little endian
buffer
ArraySegment<byte>-
The buffer
cancellationToken
CancellationToken-
The cancellation token
Returns
ReverseBuffer(ArraySegment<byte>)
Reverses the buffer using the specified buffer
internal static void ReverseBuffer(ArraySegment<byte> buffer)
Parameters
buffer
ArraySegment<byte>-
The buffer
WriteInt(int, Stream, bool)
Writes the int using the specified value
public static void WriteInt(int value, Stream stream, bool isLittleEndian)
Parameters
WriteLong(long, Stream, bool)
Writes the long using the specified value
public static void WriteLong(long value, Stream stream, bool isLittleEndian)
Parameters
WriteToStream(byte[], Stream)
Writes the to stream using the specified buffer
internal static void WriteToStream(byte[] buffer, Stream stream)
Parameters
WriteULong(ulong, Stream, bool)
Writes the u long using the specified value
public static void WriteULong(ulong value, Stream stream, bool isLittleEndian)
Parameters
WriteUShort(ushort, Stream, bool)
Writes the u short using the specified value
public static void WriteUShort(ushort value, Stream stream, bool isLittleEndian)