コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }