Esempio n. 1
0
                /// <summary>
                /// Parses out a JSON true AST node with a jsonTextReader.
                /// </summary>
                /// <param name="jsonTextReader">The reader to use as a lexer / tokenizer</param>
                /// <returns>JSON true AST node</returns>
                private static TrueNode ParseTrueNode(IJsonReader jsonTextReader)
                {
                    // consume the true token from the reader
                    jsonTextReader.Read();

                    return(TrueNode.Create());
                }
Esempio n. 2
0
            public override IJsonReader CreateReader(IJsonNavigatorNode jsonNavigatorNode)
            {
                if (!(jsonNavigatorNode is JsonTextNavigatorNode jsonTextNavigatorNode))
                {
                    throw new ArgumentException($"{nameof(jsonNavigatorNode)} must be a {nameof(JsonTextNavigatorNode)}.");
                }

                ReadOnlyMemory <byte> buffer = jsonTextNavigatorNode switch
                {
                    LazyNode lazyNode => lazyNode.BufferedValue,
                    ArrayNode arrayNode => arrayNode.BufferedValue,
                    FalseNode falseNode => SingletonBuffers.False,
                    StringNodeBase stringNodeBase => stringNodeBase.BufferedValue.Memory,
                    NullNode nullNode => SingletonBuffers.Null,
                    NumberNode numberNode => numberNode.BufferedToken,
                    ObjectNode objectNode => objectNode.BufferedValue,
                    TrueNode trueNode => SingletonBuffers.True,
                    GuidNode guidNode => guidNode.BufferedToken,
                    BinaryNode binaryNode => binaryNode.BufferedToken,
                    IntegerNode intNode => intNode.BufferedToken,
                    FloatNode floatNode => floatNode.BufferedToken,
                                      _ => throw new ArgumentOutOfRangeException($"Unknown {nameof(JsonTextNavigatorNode)} type: {jsonTextNavigatorNode.GetType()}."),
                };

                return(JsonReader.Create(JsonSerializationFormat.Text, buffer));
            }
Esempio n. 3
0
 private static ReadOnlyMemory <byte> GetNodeBuffer(JsonTextNavigatorNode jsonTextNavigatorNode)
 {
     return(jsonTextNavigatorNode switch
     {
         LazyNode lazyNode => lazyNode.BufferedValue,
         ArrayNode arrayNode => arrayNode.BufferedValue,
         FalseNode falseNode => SingletonBuffers.False,
         StringNodeBase stringNodeBase => stringNodeBase.BufferedValue.Memory,
         NullNode nullNode => SingletonBuffers.Null,
         NumberNode numberNode => numberNode.BufferedToken,
         ObjectNode objectNode => objectNode.BufferedValue,
         TrueNode trueNode => SingletonBuffers.True,
         GuidNode guidNode => guidNode.BufferedToken,
         BinaryNode binaryNode => binaryNode.BufferedToken,
         IntegerNode intNode => intNode.BufferedToken,
         FloatNode floatNode => floatNode.BufferedToken,
         _ => throw new ArgumentOutOfRangeException($"Unknown {nameof(JsonTextNavigatorNode)} type: {jsonTextNavigatorNode.GetType()}."),
     });