Exemplo n.º 1
0
 public int Read(BsonReader reader)
 {
     this.Val = reader.ReadInt64();
     return this.Size;
 }
Exemplo n.º 2
0
        public void Read(Stream stream)
        {
            /* Used during debugging of the stream.
            BsonReader headerreader = new BsonReader(stream);
            this.Header = ReadHeader(headerreader);

            //buffer the whole response into a memorystream for debugging.
            MemoryStream buffer = new MemoryStream();
            BinaryReader buffReader = new BinaryReader(stream);
            BinaryWriter buffWriter = new BinaryWriter(buffer);
            byte[] body = buffReader.ReadBytes(this.Header.MessageLength - 16);
            System.Console.WriteLine(BitConverter.ToString(body));
            buffWriter.Write(body);
            buffer.Seek(0, SeekOrigin.Begin);

            BsonReader reader = new BsonReader(buffer);*/

            BsonReader reader = new BsonReader(stream);
            this.Header = ReadHeader(reader);

            this.ResponseFlag = reader.ReadInt32();
            this.CursorID = reader.ReadInt64();
            this.StartingFrom = reader.ReadInt32();
            this.NumberReturned = reader.ReadInt32();

            List<BsonDocument> docs = new List<BsonDocument>();
            for(int num = 0; num < this.NumberReturned; num++){
                BsonDocument doc = new BsonDocument();
                doc.Read(reader);
                docs.Add(doc);
            }
            this.Documents = docs.ToArray();
        }