Beispiel #1
0
        /// <summary>
        /// 枚举类型解析
        /// </summary>
        /// <param name="value">目标数据</param>
        private unsafe void parseEnum <valueType>(ref valueType value)
        {
            BufferIndex *indexs = queryIndex + 1;

            if (indexs->Length == 0)
            {
                value = default(valueType);
            }
            else
            {
                current = bufferStart + indexs->StartIndex;
                *(current + indexs->Length) = *(current - 1) = (byte)'"';
                AutoCSer.JsonDeSerializer parser = Interlocked.Exchange(ref enumJsonParser, null);
                if (parser == null)
                {
                    parser = AutoCSer.JsonDeSerializer.YieldPool.Default.Pop() ?? new AutoCSer.JsonDeSerializer();
                    parser.SetEnum();
                }
                if (!parser.DeSerializeEnum(header.UnescapeUtf8(bufferStart, indexs->StartIndex - 1, indexs->Length + 2), ref value))
                {
                    state = HeaderQueryParseState.Unknown;
                }
                if ((parser = Interlocked.Exchange(ref enumJsonParser, parser)) != null)
                {
                    parser.Free();
                }
            }
        }
Beispiel #2
0
        protected bool parseJson <parameterType>(ref parameterType parameter, string json) where parameterType : struct
        {
            AutoCSer.JsonDeSerializer parser = Interlocked.Exchange(ref JsonParser, null) ?? AutoCSer.JsonDeSerializer.YieldPool.Default.Pop() ?? new AutoCSer.JsonDeSerializer();
            bool isParse = parser.DeSerializeWebViewNotEmpty(ref parameter, json, jsonParserConfig);

            if ((parser = Interlocked.Exchange(ref JsonParser, parser)) != null)
            {
                parser.Free();
            }
            return(isParse);
        }
Beispiel #3
0
 internal void FreeReceiveDeSerializer()
 {
     AutoCSer.BinaryDeSerializer deSerializer = Interlocked.Exchange(ref ReceiveDeSerializer, null);
     if (deSerializer != null)
     {
         deSerializer.Free();
     }
     AutoCSer.JsonDeSerializer jsonDeSerializer = Interlocked.Exchange(ref ReceiveJsonDeSerializer, null);
     if (jsonDeSerializer != null)
     {
         jsonDeSerializer.Free();
     }
 }
Beispiel #4
0
 internal void FreeReceiveDeSerializer()
 {
     if (ReceiveDeSerializer != null)
     {
         ReceiveDeSerializer.Free();
         ReceiveDeSerializer = null;
     }
     if (ReceiveJsonDeSerializer != null)
     {
         ReceiveJsonDeSerializer.Free();
         ReceiveJsonDeSerializer = null;
     }
 }
Beispiel #5
0
        internal bool DeSerializeJson <valueType>(ref SubArray <byte> data, ref valueType value)
            where valueType : struct
        {
            AutoCSer.JsonDeSerializer jsonDeSerializer = Interlocked.Exchange(ref ReceiveJsonDeSerializer, null);
            if (jsonDeSerializer == null)
            {
                jsonDeSerializer = AutoCSer.JsonDeSerializer.YieldPool.Default.Pop() ?? new AutoCSer.JsonDeSerializer();
                jsonDeSerializer.SetTcpServer();
            }
            bool isValue = jsonDeSerializer.DeSerializeTcpServer(ref data, ref value);

            if (Interlocked.CompareExchange(ref ReceiveJsonDeSerializer, jsonDeSerializer, null) != null)
            {
                jsonDeSerializer.Free();
            }
            return(isValue);
        }
Beispiel #6
0
 internal void FreeSerializer()
 {
     OutputStream = null;
     if (ReceiveDeSerializer != null)
     {
         ReceiveDeSerializer.Free();
         ReceiveDeSerializer = null;
     }
     if (ReceiveJsonParser != null)
     {
         ReceiveJsonParser.Free();
         ReceiveJsonParser = null;
     }
     if (OutputSerializer != null)
     {
         OutputSerializer.Free();
         OutputSerializer = null;
     }
     if (OutputJsonSerializer != null)
     {
         OutputJsonSerializer.Free();
         OutputJsonSerializer = null;
     }
 }