Exemple #1
0
            /// <inheritdoc />
            public override bool TryGetBufferedRawJson(
                IJsonNavigatorNode jsonNode,
                out ReadOnlyMemory <byte> bufferedRawJson)
            {
                if (jsonNode == null)
                {
                    throw new ArgumentNullException(nameof(jsonNode));
                }

                if (!(jsonNode is BinaryNavigatorNode binaryNavigatorNode))
                {
                    throw new ArgumentException($"{nameof(jsonNode)} must be a {nameof(BinaryNavigatorNode)}");
                }

                if ((this.jsonStringDictionary != null) && JsonBinaryNavigator.IsStringOrNested(binaryNavigatorNode))
                {
                    // Force a rewrite for dictionary encoding.
                    bufferedRawJson = default;
                    return(false);
                }

                ReadOnlyMemory <byte> buffer = binaryNavigatorNode.Buffer;

                if (buffer.Length == 0)
                {
                    throw new ArgumentException($"Node must not be empty.");
                }

                bufferedRawJson = buffer;
                return(true);
            }
Exemple #2
0
            private bool TryGetBufferedRawJsonInternal(
                BinaryNavigatorNode binaryNavigatorNode,
                out ReadOnlyMemory <byte> bufferedRawJson)
            {
                if ((this.jsonStringDictionary != null) && JsonBinaryNavigator.IsStringOrNested(binaryNavigatorNode))
                {
                    // Force a rewrite for dictionary encoding.
                    bufferedRawJson = default;
                    return(false);
                }

                ReadOnlyMemory <byte> buffer = binaryNavigatorNode.Buffer;

                if (buffer.Length == 0)
                {
                    throw new ArgumentException($"Node must not be empty.");
                }

                bufferedRawJson = buffer;
                return(true);
            }