public static byte[] SerializeDict(Dictionary <string, object> in_dict) { if (MSG_ENCODED == 2) { try { // transform updates dont have data sTransformUpdate entity = new sTransformUpdate(in_dict); byte[] toReturn = HudHelper.StructureToByteArray <sTransformUpdate>(entity); return(toReturn); } catch (Exception) { try { // transform updates dont have data sProjectileData entity = new sProjectileData(in_dict); byte[] toReturn = HudHelper.StructureToByteArray <sProjectileData>(entity); return(toReturn); } catch (Exception) { return(EMPTY_ARRAY); } } } return(EMPTY_ARRAY); }
public static Dictionary <string, object> DeserializeData(byte[] in_data) { if (MSG_ENCODED == 2) { Dictionary <string, object> newDict = new Dictionary <string, object>(); try { sTransformUpdate newObject = HudHelper.ByteArrayToStructure <sTransformUpdate>(in_data); newDict = newObject.ToDict(); } catch (Exception) { try { sProjectileData newObject = HudHelper.ByteArrayToStructure <sProjectileData>(in_data); newDict = newObject.ToDict(); } catch (Exception) { string result = Encoding.ASCII.GetString(in_data); if (result.Length > 0) { if (result[0] == '{') { newDict = (Dictionary <string, object>)JsonReader.Deserialize(result); } else { newDict = DeserializeString(result); } } } } return(newDict); } return(null); }