// TODO: It would be AWESOME if we could just store this class directly, but // unfortunately, Bond's type aliases allow only primitive types to be aliased. // We should check to see if we can add support for custom types in Bond's source, // but for now, we're forced to do a double serialization here. public static ArraySegment <byte> ToByteArray(IGenericSerializable Serializable) { if (Serializable == null) { return(default(ArraySegment <byte>)); } var Type = Serializable.GetType(); var Result = new SerializationGenericReference(0) { Type = BondSerializationUtil.GetTypeIdentifierString(Type), Data = BondSerializer.Serialize(Serializable) }; return(BondSerializer.Serialize(Result)); }
public static ArraySegment <byte> Convert(IGenericSerializable value, ArraySegment <byte> unused, Type ExpectedType) { return(SerializationGenericReference.ToByteArray(value)); }
public static IGenericSerializable Convert(ArraySegment <byte> value, IGenericSerializable unused, Type ExpectedType) { return(SerializationGenericReference.FromByteArray(value)); }