private static int DeSerializeClass(object _OBJ, byte[] _Buffer, int _Index) { Type type = _OBJ.GetType(); FieldInfo[] fields = type.GetFields(); if (PacketDeSerialize.btestLog) { Debug.Log(string.Concat(new object[] { "-------DeSerialize Fields------", fields.Length, " ", type.Name })); } FieldInfo[] array = fields; for (int i = 0; i < array.Length; i++) { FieldInfo fieldInfo = array[i]; object value = fieldInfo.GetValue(_OBJ); Type type2 = value.GetType(); if (PacketDeSerialize.IsFieldsType(type2)) { _Index = PacketDeSerialize.DeSerialize(value, _Buffer, _Index); } else { _Index = PacketDeSerialize.DeSerializeFieldBase(_OBJ, _Buffer, _Index, fieldInfo); } } return(_Index); }
public static object DeSerializeType(Type _Type, byte[] _Buffer, ref int _Index) { object obj = null; try { obj = Activator.CreateInstance(_Type); _Index = PacketDeSerialize.DeSerialize(obj, _Buffer, _Index); } catch (Exception ex) { Debug.Log("ex" + ex.Message); } return(obj); }
private static int DeSerializeFieldArrayBase(Array _Contexts, byte[] _Buffer, int _Index) { int num = 0; foreach (object current in _Contexts) { Type type = current.GetType(); object value; if (PacketDeSerialize.IsFieldsType(type)) { _Index = PacketDeSerialize.DeSerialize(current, _Buffer, _Index); value = current; } else { value = PacketDeSerialize.DeSerializeValue(_Buffer, ref _Index, current); } _Contexts.SetValue(value, num++); } return(_Index); }