Пример #1
0
        // private static methods
        /// <summary>
        /// Builds the bson decoding trie.
        /// </summary>
        /// <returns>A BsonTrie.</returns>
        private static BsonTrie <bool> BuildBsonTrie()
        {
            var bsonTrie = new BsonTrie <bool>();

            bsonTrie.Add("k", true); // is key
            bsonTrie.Add("v", false);
            return(bsonTrie);
        }
        public void Should_read_name_when_trie_knows_about_the_name()
        {
            var trie = new BsonTrie<int>();
            trie.Add("known", 10);

            Assert(trie, "known");
        }
        public void Should_read_name_when_trie_holds_a_longer_version_of_the_name()
        {
            var trie = new BsonTrie<int>();
            trie.Add("longer", 10);

            Assert(trie, "long");
        }
        public void Should_read_name_when_trie_does_not_know_about_the_name()
        {
            var trie = new BsonTrie<int>();
            trie.Add("known", 10);

            Assert(trie, "different");
        }
Пример #5
0
        // constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializerHelper"/> class.
        /// </summary>
        /// <param name="members">The members.</param>
        public SerializerHelper(params Member[] members)
        {
            if (members == null)
            {
                throw new ArgumentNullException("members");
            }
            if (members.Length > 64)
            {
                throw new ArgumentException("SerializerHelper supports a maximum of 64 members.", "members");
            }

            _members = members;
            _trie    = new BsonTrie <long>();

            foreach (var member in members)
            {
                _allMemberFlags |= member.Flag;
                if (!member.IsOptional)
                {
                    _requiredMemberFlags |= member.Flag;
                }

                if (member.ElementName == "*")
                {
                    _extraMemberFlag = member.Flag;
                }
                else
                {
                    _trie.Add(member.ElementName, member.Flag);
                }
            }
        }
Пример #6
0
        // constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializerHelper"/> class.
        /// </summary>
        /// <param name="members">The members.</param>
        public SerializerHelper(params Member[] members)
        {
            if (members == null)
            {
                throw new ArgumentNullException("members");
            }
            if (members.Length > 64)
            {
                throw new ArgumentException("SerializerHelper supports a maximum of 64 members.", "members");
            }

            _members = members;
            _trie = new BsonTrie<long>();

            foreach (var member in members)
            {
                _allMemberFlags |= member.Flag;
                if (!member.IsOptional)
                {
                    _requiredMemberFlags |= member.Flag;
                }

                if (member.ElementName == "*")
                {
                    _extraMemberFlag = member.Flag;
                }
                else
                {
                    _trie.Add(member.ElementName, member.Flag);
                }
            }
        }
Пример #7
0
        public void Should_read_name_when_trie_knows_about_the_name()
        {
            var trie = new BsonTrie <int>();

            trie.Add("known", 10);

            Assert(trie, "known");
        }
Пример #8
0
        public void Should_read_name_when_trie_holds_a_longer_version_of_the_name()
        {
            var trie = new BsonTrie <int>();

            trie.Add("longer", 10);

            Assert(trie, "long");
        }
Пример #9
0
        public void Should_read_name_when_trie_does_not_know_about_the_name()
        {
            var trie = new BsonTrie <int>();

            trie.Add("known", 10);

            Assert(trie, "different");
        }