/// <summary> /// Writes the body. /// </summary> /// <param name="writer">The writer.</param> protected override void WriteBody(BsonWriter writer){ writer.WriteValue(BsonType.Integer, 0); writer.Write(FullCollectionName, false); writer.WriteValue(BsonType.Integer, Flags); writer.WriteObject(Selector); writer.WriteObject(Document); }
/// <summary> /// Writes the body. /// </summary> /// <param name="writer">The writer.</param> protected override void WriteBody(BsonWriter writer){ writer.WriteValue(BsonType.Integer, 0); writer.WriteValue(BsonType.Integer, CursorIds.Length); foreach(var id in CursorIds) writer.WriteValue(BsonType.Long, id); }
public void TestWriteArrayDoc() { const string expected = "2000000002300002000000610002310002000000620002320002000000630000"; var ms = new MemoryStream(); var writer = new BsonWriter(ms, new BsonDocumentDescriptor()); var str = new[] {"a", "b", "c"}; writer.WriteValue(BsonType.Array, str); var hexdump = BitConverter.ToString(ms.ToArray()); hexdump = hexdump.Replace("-", ""); Assert.AreEqual(expected, hexdump); }
public void TestWriteSymbol() { var expected = "0700000073796D626F6C00"; var ms = new MemoryStream(); var writer = new BsonWriter(ms, new BsonDocumentDescriptor()); MongoSymbol val = "symbol"; Assert.IsTrue(String.IsInterned(val) != null); writer.WriteValue(BsonType.Symbol, val); var hexdump = BitConverter.ToString(ms.ToArray()).Replace("-", ""); Assert.AreEqual(expected, hexdump); }
public void TestWriteSingle() { var expected = "000000E0FFFFEF47"; var ms = new MemoryStream(); var writer = new BsonWriter(ms, new BsonDocumentDescriptor()); var val = Single.MaxValue; writer.WriteValue(BsonType.Number, val); var hexdump = BitConverter.ToString(ms.ToArray()); hexdump = hexdump.Replace("-", ""); Assert.AreEqual(expected, hexdump); }
/// <summary> /// Writes the body. /// </summary> /// <param name="writer">The writer.</param> protected override void WriteBody(BsonWriter writer){ writer.WriteValue(BsonType.Integer, (int)Options); writer.Write(FullCollectionName, false); writer.WriteValue(BsonType.Integer, NumberToSkip); writer.WriteValue(BsonType.Integer, NumberToReturn); writer.WriteObject(Query); if(ReturnFieldSelector != null) writer.WriteObject(ReturnFieldSelector); }
/// <summary> /// Writes out a header and the chunk of documents. /// </summary> /// <param name = "stream"></param> /// <param name = "chunk"></param> protected void WriteChunk(Stream stream, MessageChunk chunk){ WriteHeader(new BinaryWriter(stream), chunk.Size); var writer = new BsonWriter(stream, _bsonWriterSettings); writer.WriteValue(BsonType.Integer, 0); writer.Write(FullCollectionName, false); foreach(var document in chunk.Documents) writer.WriteObject(document); writer.Flush(); }
/// <summary> /// Writes the body. /// </summary> /// <param name="writer">The writer.</param> protected override void WriteBody(BsonWriter writer){ writer.WriteValue(BsonType.Integer, 0); writer.Write(FullCollectionName, false); writer.WriteValue(BsonType.Integer, NumberToReturn); writer.WriteValue(BsonType.Long, CursorId); }