Class Utils.ProtoBuf
- Namespace
- RichHudFramework
- Assembly
- RichHudClient.dll
Safe wrappers around Space Engineers' built-in ProtoBuf serialization utilities. Catches exceptions and returns them as KnownException instead of letting them propagate.
public static class Utils.ProtoBuf
- Inheritance
-
Utils.ProtoBuf
Methods
TryDeserialize<T>(byte[], out T)
Attempts to deserialize a byte array into an object of the specified type using ProtoBuf.
Wraps MyAPIGateway.Utilities.SerializeFromBinary()
public static KnownException TryDeserialize<T>(byte[] dataIn, out T obj)
Parameters
dataInbyte[]The byte array containing serialized data.
objTReceives the deserialized instance on success; default(T) on failure.
Returns
- KnownException
Null on success, otherwise a KnownException describing the failure.
Type Parameters
TTarget type. Must match the type used during serialization.
TrySerialize<T>(T, out byte[])
Attempts to serialize an object to a binary byte array using ProtoBuf.
Wraps MyAPIGateway.Utilities.SerializeToBinary().
public static KnownException TrySerialize<T>(T obj, out byte[] dataOut)
Parameters
objTThe object instance to serialize.
dataOutbyte[]Receives the serialized byte array on success; null on failure.
Returns
- KnownException
Null on success, otherwise a KnownException describing the failure.
Type Parameters
TType of the object to serialize. Must be marked [ProtoContract] with members marked [ProtoMember(uniqueID)].