コード例 #1
0
ファイル: Delete.cs プロジェクト: automatonic/mongodb-net
 /// <summary>
 /// Writes the body.
 /// </summary>
 /// <param name="writer">The writer.</param>
 protected override void WriteBody(WireProtocolWriter writer)
 {
     writer.Write(0);
     writer.WriteNullTerminated(FullNameSpace);
     writer.Write(DeleteQuery.HasOid() ? 1 : 0);
     WriteDBObject(writer, DeleteQuery);
 }
コード例 #2
0
ファイル: GetMore.cs プロジェクト: cole2295/mongodb-net
 /// <summary>
 /// Writes the body.
 /// </summary>
 /// <param name="writer">The writer.</param>
 protected override void WriteBody(WireProtocolWriter writer)
 {
     writer.Write(0);
     writer.WriteNullTerminated(Cursor.Options.Collection.FullName);
     writer.Write(Cursor.Options.NumberToReturn);
     writer.Write(Cursor.CursorID.Value);
 }
コード例 #3
0
ファイル: KillCursors.cs プロジェクト: cole2295/mongodb-net
 /// <summary>
 /// Writes the body.
 /// </summary>
 /// <param name="writer">The writer.</param>
 protected override void WriteBody(WireProtocolWriter writer)
 {
     writer.Write(0);
     writer.Write(this.CursorIDs.Count);
     foreach (long cursorID in CursorIDs)
     {
         writer.Write(cursorID);
     }
 }
コード例 #4
0
ファイル: Query.cs プロジェクト: automatonic/mongodb-net
        /// <summary>
        /// Writes the body.
        /// </summary>
        /// <param name="writer">The writer.</param>
        protected override void WriteBody(WireProtocolWriter writer)
        {
            writer.Write((int)Options.Flags);
            writer.WriteNullTerminated(Options.Collection.FullName);
            writer.Write(Options.NumberToSkip.HasValue ? Options.NumberToSkip.Value : 0);
            writer.Write(Options.NumberToReturn);
            writer.Write(Options.Selector);

            if (Options.ReturnFields != null)
                writer.Write(Options.ReturnFields);
        }
コード例 #5
0
        public void TestWriteInt()
        {
            MemoryStream ms = new MemoryStream();
            WireProtocolWriter writer = new WireProtocolWriter(ms);
            string expected = "01-00-00-00";
            writer.Write(1);

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

            Assert.AreEqual(expected, hexdump);
        }
コード例 #6
0
        public void TestWriteArrayDoc()
        {
            String expected = "2000000002300002000000610002310002000000620002320002000000630000";
            MemoryStream ms = new MemoryStream();
            WireProtocolWriter writer = new WireProtocolWriter(ms);

            String[] str = new String[] { "a", "b", "c" };
            writer.Write(new DBObjectArray((IList)str));

            string hexdump = BitConverter.ToString(ms.ToArray());
            hexdump = hexdump.Replace("-", "");
            Assert.AreEqual(expected, hexdump);
        }
コード例 #7
0
        public void TestWriteDocument()
        {
            MemoryStream ms = new MemoryStream();
            WireProtocolWriter writer = new WireProtocolWriter(ms);
            string expected = "1400000002746573740005000000746573740000";
            DBObject doc = new DBObject("test", "test");

            writer.Write(doc);

            string hexdump = BitConverter.ToString(ms.ToArray());
            hexdump = hexdump.Replace("-", "");

            Assert.AreEqual(expected, hexdump);
        }
コード例 #8
0
ファイル: Update.cs プロジェクト: automatonic/mongodb-net
 /// <summary>
 /// Writes the body.
 /// </summary>
 /// <param name="writer">The writer.</param>
 protected override void WriteBody(WireProtocolWriter writer)
 {
     writer.Write(0);
     writer.WriteNullTerminated(FullNameSpace);
     writer.Write((int)Flags);
     writer.Write(Selector);
     writer.Write(Document);
 }
コード例 #9
0
ファイル: Insert.cs プロジェクト: cole2295/mongodb-net
 /// <summary>
 /// Writes the body.
 /// </summary>
 /// <param name="writer">The writer.</param>
 protected override void WriteBody(WireProtocolWriter writer)
 {
     writer.Write(0);
     writer.WriteNullTerminated(FullCollectionName);
     foreach (IDBObject document in _documents)
     {
         WriteDBObject(writer, document);
     }
 }
コード例 #10
0
ファイル: Header.cs プロジェクト: cole2295/mongodb-net
 /// <summary>
 /// Writes the DB object.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="dbo">The dbo.</param>
 protected virtual void WriteDBObject(WireProtocolWriter writer, IDBObject dbo)
 {
     writer.Write(dbo);
 }
コード例 #11
0
ファイル: Header.cs プロジェクト: cole2295/mongodb-net
 /// <summary>
 /// Writes the specified writer.
 /// </summary>
 /// <param name="writer">The writer.</param>
 public void Write(WireProtocolWriter writer)
 {
     //Write the header
     int start = writer.Position;
     writer.Write(MessageLength); //placeholder for size
     writer.Write(RequestID);
     writer.Write(ResponseTo);
     writer.Write((int)OpCode);
     //Write the payload
     WriteBody(writer);
     int finish = writer.Position;
     writer.Seek(start, SeekOrigin.Begin);
     MessageLength = finish - start;
     writer.Write(MessageLength);
     writer.Seek(finish, SeekOrigin.Begin);
 }