// public methods
        /// <summary>
        /// Reads the name.
        /// </summary>
        /// <param name="streamReader">The stream reader.</param>
        /// <returns>
        /// The name.
        /// </returns>
        public string Decode(BsonStreamReader streamReader)
        {
            BsonTrieNode <TValue> node;

            if (_trie.TryGetNode(streamReader, out node))
            {
                if (node.HasValue)
                {
                    _found = true;
                    _value = node.Value;
                    return(node.ElementName);
                }
            }

            return(streamReader.ReadCString());
        }
Beispiel #2
0
        // public methods
        /// <summary>
        /// Reads the name.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="encoding">The encoding.</param>
        /// <returns>
        /// The name.
        /// </returns>
        public string Decode(BsonStream stream, UTF8Encoding encoding)
        {
            BsonTrieNode <TValue> node;

            if (_trie.TryGetNode(stream, out node))
            {
                if (node.HasValue)
                {
                    _found = true;
                    _value = node.Value;
                    return(node.ElementName);
                }
            }

            return(stream.ReadCString(encoding));
        }
Beispiel #3
0
        // public methods
        /// <summary>
        /// Reads the name.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="encoding">The encoding.</param>
        /// <returns>
        /// The name.
        /// </returns>
        public string Decode(BsonStream stream, UTF8Encoding encoding)
        {
            BsonTrieNode <TValue> node;
            var oldPosition = stream.Position;

            if (_trie.TryGetNode(stream, out node))
            {
                if (node.HasValue)
                {
                    _found = true;
                    _value = node.Value;
                    return(node.ElementName);
                }

                stream.Position = oldPosition;
            }

            _found = false;
            _value = default;

            return(stream.ReadCString(encoding));
        }