WriteValue() public method

public WriteValue ( BsonDataType dt, Object obj ) : void
dt BsonDataType
obj Object
return void
Example #1
0
 protected override void WriteBody(BsonWriter writer)
 {
     writer.WriteValue(BsonDataType.Integer,0);
     writer.WriteString(this.FullCollectionName);
     writer.WriteValue(BsonDataType.Integer,0);
     writer.Write(this.Selector);
 }
 protected override void WriteBody(BsonWriter writer)
 {
     writer.WriteValue(BsonDataType.Integer,0);
     writer.WriteString(this.FullCollectionName);
     writer.WriteValue(BsonDataType.Integer,this.NumberToReturn);
     writer.WriteValue(BsonDataType.Long,this.CursorID);
 }
        protected override void WriteBody(BsonWriter writer)
        {
            writer.WriteValue(BsonDataType.Integer,0);
            writer.WriteValue(BsonDataType.Integer, this.CursorIDs.Length);

            foreach(long id in this.CursorIDs){
                writer.WriteValue(BsonDataType.Long, id);
            }
        }
Example #4
0
        public void TestWriteArrayDoc()
        {
            String expected = "2000000002300002000000610002310002000000620002320002000000630000";
            MemoryStream ms = new MemoryStream();
            BsonWriter writer = new BsonWriter(ms);

            String[] str = new String[]{"a","b","c"};
            writer.WriteValue(BsonDataType.Array,str);

            string hexdump = BitConverter.ToString(ms.ToArray());
            hexdump = hexdump.Replace("-","");
            Assert.AreEqual(expected, hexdump);
        }
Example #5
0
        public void TestWriteArrayDoc()
        {
            String       expected = "2000000002300002000000610002310002000000620002320002000000630000";
            MemoryStream ms       = new MemoryStream();
            BsonWriter   writer   = new BsonWriter(ms);

            String[] str = new String[] { "a", "b", "c" };
            writer.WriteValue(BsonDataType.Array, str);

            string hexdump = BitConverter.ToString(ms.ToArray());

            hexdump = hexdump.Replace("-", "");
            Assert.AreEqual(expected, hexdump);
        }
        /// <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);

            BsonWriter writer = new BsonWriter(stream);
            writer.WriteValue(BsonDataType.Integer,0);
            writer.WriteString(this.FullCollectionName);

            foreach(Document doc in chunk.Documents){
                writer.Write(doc);
            }
            writer.Flush();
        }
Example #7
0
 protected override void WriteBody(BsonWriter writer)
 {
     writer.WriteValue(BsonDataType.Integer,(int)this.Options);
     writer.WriteString(this.FullCollectionName);
     writer.WriteValue(BsonDataType.Integer,(int)this.NumberToSkip);
     writer.WriteValue(BsonDataType.Integer,(int)this.NumberToReturn);
     writer.Write(this.Query);
     if(this.ReturnFieldSelector != null){
         writer.Write(this.ReturnFieldSelector);
     }
 }