Photon Server API

Static Public Member Functions | List of all members
ExitGames.IO.BinaryConverter Class Reference

This class converts binary data to streams and vice versa and de-/serialzes objects with the BinaryFormatter. More...

Static Public Member Functions

static byte[] ConvertStreamToByteArray (Stream data, int length)
 Converts a stream to a byte array. More...
 
static T Deserialize< T > (byte[] bytes, int index, int count)
 Converts a byte array to an object of type T with the BinaryFormatter. More...
 
static T Deserialize< T > (byte[] bytes)
 Converts a byte array to an object of type T with the BinaryFormatter. More...
 
static IFormatter GetBinaryFormatterThreadStatic ()
 Gets a thread static BinaryFormatter. More...
 
static byte[] ReadBytesFromStream (Stream data, int length)
 Reads the given amount of bytes from a stream. More...
 
static byte[] Serialize< T > (ref T data)
 Serializes an object of type T. More...
 

Detailed Description

This class converts binary data to streams and vice versa and de-/serialzes objects with the BinaryFormatter.

Member Function Documentation

◆ ConvertStreamToByteArray()

static byte [] ExitGames.IO.BinaryConverter.ConvertStreamToByteArray ( Stream  data,
int  length 
)
inlinestatic

Converts a stream to a byte array.

Parameters
dataThe data.
lengthThe length.
Returns
A byte array.
Exceptions
ArgumentNullExceptiondata is null.

◆ Deserialize< T >() [1/2]

static T ExitGames.IO.BinaryConverter.Deserialize< T > ( byte[]  bytes)
inlinestatic

Converts a byte array to an object of type T with the BinaryFormatter.

Parameters
bytesThe bytes.
Template Parameters
TThe object type.
Returns
An object of type T.

◆ Deserialize< T >() [2/2]

static T ExitGames.IO.BinaryConverter.Deserialize< T > ( byte[]  bytes,
int  index,
int  count 
)
inlinestatic

Converts a byte array to an object of type T with the BinaryFormatter.

Template Parameters
TThe object type.
Parameters
bytesA serialized object of Type T.
indexThe start index.
countThe length to the serialized object.
Returns
An object of type T.

◆ GetBinaryFormatterThreadStatic()

static IFormatter ExitGames.IO.BinaryConverter.GetBinaryFormatterThreadStatic ( )
inlinestatic

Gets a thread static BinaryFormatter.

Returns
A thread static BinaryFormatter.

◆ ReadBytesFromStream()

static byte [] ExitGames.IO.BinaryConverter.ReadBytesFromStream ( Stream  data,
int  length 
)
inlinestatic

Reads the given amount of bytes from a stream.

Parameters
dataThe stream.
lengthThe length to read.
Returns
A byte array.
Exceptions
ArgumentNullExceptiondata is null.

◆ Serialize< T >()

static byte [] ExitGames.IO.BinaryConverter.Serialize< T > ( ref T  data)
inlinestatic

Serializes an object of type T.

Template Parameters
TThe object type.
Parameters
dataThe object to serialize.
Returns
A byte array.