Class Serializer
Platform independent serialization of values in Big-endian (network byte order).
Inheritance
Namespace: SuperNet.Netcode.Util
Assembly: cs.temp.dll.dll
Syntax
public static class Serializer
Properties
Encoding
Character encoding to use when serializing strings.
Declaration
public static Encoding Encoding { get; }
Property Value
Type | Description |
---|---|
Encoding |
Methods
ReadDouble(Byte[], Int32)
Deserialize double (8 bytes) from the buffer.
Declaration
public static double ReadDouble(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.Double | Deserialized value. |
ReadInt16(Byte[], Int32)
Deserialize short (2 bytes) from the buffer.
Declaration
public static short ReadInt16(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.Int16 | Deserialized value. |
ReadInt32(Byte[], Int32)
Deserialize int (4 bytes) from the buffer.
Declaration
public static int ReadInt32(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.Int32 | Deserialized value. |
ReadInt64(Byte[], Int32)
Deserialize long (8 bytes) from the buffer.
Declaration
public static long ReadInt64(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.Int64 | Deserialized value. |
ReadSingle(Byte[], Int32)
Deserialize float (4 bytes) from the buffer.
Declaration
public static float ReadSingle(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.Single | Deserialized value. |
ReadUInt16(Byte[], Int32)
Deserialize ushort (2 bytes) from the buffer.
Declaration
public static ushort ReadUInt16(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.UInt16 | Deserialized value. |
ReadUInt32(Byte[], Int32)
Deserialize uint (4 bytes) from the buffer.
Declaration
public static uint ReadUInt32(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.UInt32 | Deserialized value. |
ReadUInt64(Byte[], Int32)
Deserialize ulong (8 bytes) from the buffer.
Declaration
public static ulong ReadUInt64(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to read from. |
System.Int32 | offset | Buffer offset to read from. |
Returns
Type | Description |
---|---|
System.UInt64 | Deserialized value. |
Write16(Byte[], Int32, Int16)
Serialize short (2 bytes) to the buffer.
Declaration
public static void Write16(byte[] buffer, int offset, short value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.Int16 | value | Value to write. |
Write16(Byte[], Int32, UInt16)
Serialize ushort (2 bytes) to the buffer.
Declaration
public static void Write16(byte[] buffer, int offset, ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.UInt16 | value | Value to write. |
Write32(Byte[], Int32, Int32)
Serialize int (4 bytes) to the buffer.
Declaration
public static void Write32(byte[] buffer, int offset, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.Int32 | value | Value to write. |
Write32(Byte[], Int32, UInt32)
Serialize uint (4 bytes) to the buffer.
Declaration
public static void Write32(byte[] buffer, int offset, uint value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.UInt32 | value | Value to write. |
Write64(Byte[], Int32, Int64)
Serialize long (8 bytes) to the buffer.
Declaration
public static void Write64(byte[] buffer, int offset, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.Int64 | value | Value to write. |
Write64(Byte[], Int32, UInt64)
Serialize ulong (8 bytes) to the buffer.
Declaration
public static void Write64(byte[] buffer, int offset, ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.UInt64 | value | Value to write. |
WriteDouble(Byte[], Int32, Double)
Serialize double (8 bytes) to the buffer.
Declaration
public static void WriteDouble(byte[] buffer, int offset, double value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.Double | value | Value to write. |
WriteSingle(Byte[], Int32, Single)
Serialize float (4 bytes) to the buffer.
Declaration
public static void WriteSingle(byte[] buffer, int offset, float value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer to write to. |
System.Int32 | offset | Buffer offset to write to. |
System.Single | value | Value to write. |