예제 #1
0
 public void TestWriteCStringThrowsWhenValueContainsNulls()
 {
     using (var bsonBuffer = new BsonBuffer())
     {
         Assert.Throws <ArgumentException>(() => { bsonBuffer.WriteCString((UTF8Encoding)Encoding.UTF8, "a\0b"); });
     }
 }
예제 #2
0
 public void TestWriteCStringThrowsWhenValueIsNull()
 {
     using (var bsonBuffer = new BsonBuffer())
     {
         Assert.Throws <ArgumentNullException>(() => { bsonBuffer.WriteCString((UTF8Encoding)Encoding.UTF8, null); });
     }
 }
 // protected methods
 protected override void WriteBody(BsonBuffer buffer)
 {
     buffer.WriteInt32(0); // reserved
     buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
     buffer.WriteInt32(_numberToReturn);
     buffer.WriteInt64(_cursorId);
 }
예제 #4
0
 // protected methods
 protected override void WriteBody(BsonBuffer buffer)
 {
     buffer.WriteInt32((int)_flags);
     buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
     _firstDocumentStartPosition = buffer.Position;
     // documents to be added later by calling AddDocument
 }
예제 #5
0
 internal override void WriteHeaderTo(BsonBuffer buffer)
 {
     base.WriteHeaderTo(buffer);
     buffer.WriteInt32(0); // reserved
     buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
     buffer.WriteInt32((int)_flags);
 }
예제 #6
0
 internal override void WriteHeaderTo(BsonBuffer buffer)
 {
     _batchStartPosition = buffer.Position;
     base.WriteHeaderTo(buffer);
     buffer.WriteInt32((int)_flags);
     buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
 }
 internal override void WriteHeaderTo(BsonBuffer buffer)
 {
     base.WriteHeaderTo(buffer);
     buffer.WriteInt32((int)_flags);
     buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
     buffer.WriteInt32(_numberToSkip);
     buffer.WriteInt32(_numberToReturn);
 }
        internal override void WriteHeaderTo(BsonBuffer buffer)
        {
            if ((_flags & QueryFlags.Exhaust) != 0)
            {
                throw new NotSupportedException("The Exhaust QueryFlag is not yet supported.");
            }

            base.WriteHeaderTo(buffer);
            buffer.WriteInt32((int)_flags);
            buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
            buffer.WriteInt32(_numberToSkip);
            buffer.WriteInt32(_numberToReturn);
        }
        // protected methods
        protected override void WriteBody(BsonBuffer buffer)
        {
            buffer.WriteInt32(0); // reserved
            buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
            buffer.WriteInt32((int)_flags);

            using (var bsonWriter = new BsonBinaryWriter(buffer, false, WriterSettings))
            {
                if (_query == null)
                {
                    bsonWriter.WriteStartDocument();
                    bsonWriter.WriteEndDocument();
                }
                else
                {
                    BsonSerializer.Serialize(bsonWriter, _query.GetType(), _query, DocumentSerializationOptions.SerializeIdFirstInstance);
                }
            }
        }