internal static void SubArrayDeSerialize <valueType>(BinaryDeSerializer deSerializer, ref SubArray <valueType> value)
        {
            valueType[] array = null;
            deSerializer.isReferenceArray = false;
            TypeDeSerializer <valueType[]> .DefaultDeSerializer(deSerializer, ref array);

            value.Set(array, 0, array.Length);
        }
Beispiel #2
0
        /// <summary>
        /// JSON 解析
        /// </summary>
        /// <typeparam name="valueType">目标数据类型</typeparam>
        /// <param name="json">JSON 字符串</param>
        /// <param name="value">目标数据</param>
        /// <returns>是否解析成功</returns>
        internal bool DeSerializeEnum <valueType>(string json, ref valueType value)
        {
            //MemberMap = null;
            //anonymousTypes.Null();
            fixed(char *jsonFixed = json)
            {
                Current          = this.jsonFixed = jsonFixed;
                end              = jsonFixed + json.Length;
                DeSerializeState = DeSerializeState.Success;
                TypeDeSerializer <valueType> .DefaultDeSerializer(this, ref value);
            }

            return(DeSerializeState == DeSerializeState.Success && Current == end);
        }
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <typeparam name="valueType">数据类型</typeparam>
        /// <param name="data">数据</param>
        /// <param name="value">目标对象</param>
        /// <returns>是否成功</returns>
        internal bool DeSerializeTcpServer <valueType>(ref SubArray <byte> data, ref valueType value)
        {
            if (data.Length >= sizeof(int) * 3 && (data.Length & 3) == 0)
            {
                fixed(byte *dataFixed = (Buffer = data.GetFixedBuffer()))
                {
                    start = dataFixed + (bufferIndex = data.Start);
                    int length = data.Length - sizeof(int);

                    End = start + length;
                    if (((uint)(*(int *)End ^ length) | ((*(uint *)start & SerializeConfig.HeaderMapAndValue) ^ SerializeConfig.HeaderMapValue)) == 0)
                    {
                        //MemberMap = null;
                        getGlobalVersion();
                        if (isReferenceMember == TypeDeSerializer <valueType> .IsReferenceMember)
                        {
                            if (points != null)
                            {
                                points.Clear();
                            }
                        }
                        else
                        {
                            if (isReferenceMember)
                            {
                                isReferenceMember = false;
                            }
                            else
                            {
                                isReferenceMember = true;
                                if (points == null)
                                {
                                    points = ReusableDictionary.CreateInt <object>();
                                }
                                else
                                {
                                    points.Clear();
                                }
                            }
                        }
                        isReferenceArray = true;
                        State            = DeSerializeState.Success;
                        TypeDeSerializer <valueType> .DeSerializeTcpServer(this, ref value);

                        return(State == DeSerializeState.Success && Read == End);
                    }
                }
            }
            return(false);
        }
Beispiel #4
0
        ///// <summary>
        ///// 反序列化
        ///// </summary>
        ///// <typeparam name="valueType">数据类型</typeparam>
        ///// <param name="data">数据</param>
        ///// <param name="value">目标对象</param>
        ///// <returns>是否成功</returns>
        //[MethodImpl(AutoCSer.MethodImpl.AggressiveInlining)]
        //internal bool DeSerializeTcpServer<valueType>(byte[] data, ref valueType value)
        //{
        //    fixed (byte* dataFixed = data)
        //    {
        //        end = (jsonFixed = Current = (char*)dataFixed) + (data.Length >> 1);
        //        return deSerializeTcpServer(ref value);
        //    }
        //}
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <typeparam name="valueType"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        private bool deSerializeTcpServer <valueType>(ref valueType value)
        {
            //MemberMap = null;
            //anonymousTypes.Null();
            if (endChar != *(end - 1))
            {
                if (((endChar = *(end - 1)) & 0xff00) == 0)
                {
                    isEndSpace = (bits[(byte)endChar] & AutoCSer.JsonDeSerializer.DeSerializeSpaceBit) == 0;
                    if ((uint)(endChar - '0') < 10)
                    {
                        isEndDigital = isEndHex = isEndNumber = true;
                    }
                    else
                    {
                        isEndDigital = false;
                        if ((uint)((endChar | 0x20) - 'a') < 6)
                        {
                            isEndHex = isEndNumber = true;
                        }
                        else
                        {
                            isEndHex    = false;
                            isEndNumber = (bits[(byte)endChar] & AutoCSer.JsonDeSerializer.DeSerializeNumberBit) == 0;
                        }
                    }
                }
                else
                {
                    isEndSpace = isEndDigital = isEndHex = isEndNumber = false;
                }
            }
            DeSerializeState = DeSerializeState.Success;
            TypeDeSerializer <valueType> .DeSerializeTcpServer(this, ref value);

            if (DeSerializeState == DeSerializeState.Success)
            {
                if (Current == end)
                {
                    return(true);
                }
                space();
                return(DeSerializeState == DeSerializeState.Success && Current == end);
            }
            return(false);
        }