Peek() public method

Peeks at the next token. This peek implementation reads the next token and makes the subsequent Read() return the same data. If Peek is called successively, it will return the same data. Only the first one calls Read(), subsequent calls will return the same data until a Read() call is made.
public Peek ( JsonToken token ) : bool
token JsonToken Token to peek.
return bool
コード例 #1
0
        public List <I> Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(new List <I>());
            }
            List <I> list = new AlwaysSendList <I>();

            while (!context.Peek(JsonToken.ArrayEnd))
            {
                list.Add(iUnmarshaller.Unmarshall(context));
            }
            context.Read();
            return(list);
        }
コード例 #2
0
        public List <I> Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read(); // Read [ or null
            List <I> list = new List <I>();

            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(list);
            }

            while (!context.Peek(JsonToken.ArrayEnd)) // Peek for ]
            {
                list.Add(iUnmarshaller.Unmarshall(context));
            }
            context.Read(); // Read ]
            return(list);
        }
コード例 #3
0
        public Dictionary <TKey, TValue> Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(new Dictionary <TKey, TValue>());
            }
            Dictionary <TKey, TValue> dictionary = new AlwaysSendDictionary <TKey, TValue>();

            while (!context.Peek(JsonToken.ObjectEnd))
            {
                KeyValuePair <TKey, TValue> keyValuePair = KVUnmarshaller.Unmarshall(context);
                dictionary.Add(keyValuePair.Key, keyValuePair.Value);
            }
            context.Read();
            return(dictionary);
        }
コード例 #4
0
        public Dictionary <K, V> Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read(); // Read { or null
            Dictionary <K, V> dictionary = new Dictionary <K, V>();

            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(dictionary);
            }

            while (!context.Peek(JsonToken.ObjectEnd)) // Peek }
            {
                KeyValuePair <K, V> item = KVUnmarshaller.Unmarshall(context);
                dictionary.Add(item.Key, item.Value);
            }
            context.Read(); // Read }
            return(dictionary);
        }
コード例 #5
0
        public List <I> Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read(); // Read [ or null
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(new List <I>());
            }

            // If a list is present in the response, use AlwaysSendList,
            // so if the response was empty, reusing the object in the request we will
            // end up sending the same empty collection back.
            List <I> list = new AlwaysSendList <I>();

            while (!context.Peek(JsonToken.ArrayEnd)) // Peek for ]
            {
                list.Add(iUnmarshaller.Unmarshall(context));
            }
            context.Read(); // Read ]
            return(list);
        }
コード例 #6
0
        public Dictionary <TKey, TValue> Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read(); // Read { or null
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(new Dictionary <TKey, TValue>());
            }

            // If a dictionary is present in the response, use AlwaysSendDictionary,
            // so if the response was empty, reusing the object in the request we will
            // end up sending the same empty collection back.
            Dictionary <TKey, TValue> dictionary = new AlwaysSendDictionary <TKey, TValue>();

            while (!context.Peek(JsonToken.ObjectEnd)) // Peek }
            {
                KeyValuePair <TKey, TValue> item = KVUnmarshaller.Unmarshall(context);
                dictionary.Add(item.Key, item.Value);
            }
            context.Read(); // Read }
            return(dictionary);
        }