private static byte[] SerializeFieldBaseArray(Array _Contexts) { ByteBlock byteBlock = new ByteBlock(); foreach (object current in _Contexts) { byte[] buffer = PacketSerialize.Serialize(current); byteBlock.Add(buffer); } return(byteBlock.GetAlloc()); }
private static byte[] SerializeClass(object _OBJ) { Type type = _OBJ.GetType(); FieldInfo[] fields = type.GetFields(); ByteBlock byteBlock = new ByteBlock(); if (PacketSerialize.btestLog) { Debug.Log(string.Concat(new object[] { "-------Serialize GetFields------", fields.Length, " NAME:", type.Name })); } int num = 0; FieldInfo[] array = fields; for (int i = 0; i < array.Length; i++) { FieldInfo fieldInfo = array[i]; object value = fieldInfo.GetValue(_OBJ); Type type2 = value.GetType(); byte[] array2; if (PacketSerialize.IsFieldsType(type2)) { array2 = PacketSerialize.Serialize(value); } else { array2 = PacketSerialize.SerializeFieldBase(value); } byteBlock.Add(array2); if (PacketSerialize.btestLog) { string text = string.Empty; text += num++; string text2 = text; text = string.Concat(new object[] { text2, "Class:", fieldInfo.DeclaringType, " Name:", fieldInfo.Name, " Type:", fieldInfo.FieldType, " Value:", value.ToString() }); if (array2 != null && 0 < array2.Length) { text2 = text; text = string.Concat(new object[] { text2, " Buffer:", array2.Length, "--" }); byte[] array3 = array2; for (int j = 0; j < array3.Length; j++) { byte b = array3[j]; text = text + b.ToString() + " "; } } Debug.Log(text); } } return(byteBlock.GetAlloc()); }