예제 #1
0
        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)'"';
                Json.Parser parser = Interlocked.Exchange(ref enumJsonParser, null);
                if (parser == null)
                {
                    parser = Json.Parser.YieldPool.Default.Pop() ?? new Json.Parser();
                    parser.SetEnum();
                }
                if (!parser.ParseEnum(header.UnescapeUtf8(bufferStart, indexs->StartIndex - 1, indexs->Length + 2), ref value))
                {
                    state = HeaderQueryParseState.Unknown;
                }
                if ((parser = Interlocked.Exchange(ref enumJsonParser, parser)) != null)
                {
                    parser.Free();
                }
            }
        }
예제 #2
0
        protected bool parseJson <parameterType>(ref parameterType parameter, string json) where parameterType : struct
        {
            Json.Parser parser  = Interlocked.Exchange(ref JsonParser, null) ?? Json.Parser.YieldPool.Default.Pop() ?? new Json.Parser();
            bool        isParse = parser.ParseWebViewNotEmpty(ref parameter, json, jsonParserConfig);

            if ((parser = Interlocked.Exchange(ref JsonParser, parser)) != null)
            {
                parser.Free();
            }
            return(isParse);
        }
예제 #3
0
 internal void FreeReceiveDeSerializer()
 {
     if (ReceiveDeSerializer != null)
     {
         ReceiveDeSerializer.Free();
         ReceiveDeSerializer = null;
     }
     if (ReceiveJsonParser != null)
     {
         ReceiveJsonParser.Free();
         ReceiveJsonParser = null;
     }
 }
예제 #4
0
 internal void FreeReceiveDeSerializer()
 {
     BinarySerialize.DeSerializer deSerializer = Interlocked.Exchange(ref ReceiveDeSerializer, null);
     if (deSerializer != null)
     {
         deSerializer.Free();
     }
     Json.Parser parser = Interlocked.Exchange(ref ReceiveJsonParser, null);
     if (parser != null)
     {
         parser.Free();
     }
 }
예제 #5
0
        internal bool ParseJson <valueType>(ref SubArray <byte> data, ref valueType value)
            where valueType : struct
        {
            Json.Parser parser = Interlocked.Exchange(ref ReceiveJsonParser, null);
            if (parser == null)
            {
                parser = Json.Parser.YieldPool.Default.Pop() ?? new Json.Parser();
                parser.SetTcpServer();
            }
            bool isValue = parser.ParseTcpServer(ref data, ref value);

            if (Interlocked.CompareExchange(ref ReceiveJsonParser, parser, null) != null)
            {
                parser.Free();
            }
            return(isValue);
        }
예제 #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;
     }
 }