示例#1
0
        private void encodeArray(MemoryStream ms, BSONArray lst)
        {
            var obj = new BSONObject();

            for (int i = 0; i < lst.Count; ++i)
            {
                obj.Add(Convert.ToString(i), lst[i]);
            }

            this.encodeDocument(ms, obj);
        }
示例#2
0
        private BSONObject decodeDocument()
        {
            int length = this.mBinaryReader.ReadInt32() - 4;

            BSONObject obj = new BSONObject();

            int i = (int)this.mBinaryReader.BaseStream.Position;

            while (this.mBinaryReader.BaseStream.Position < i + length - 1)
            {
                BSONValue value = this.decodeElement(out string name);
                obj.Add(name, value);
            }

            this.mBinaryReader.ReadByte(); // zero
            return(obj);
        }