public void TestWriteCStringThrowsWhenValueContainsNulls() { using (var bsonBuffer = new BsonBuffer()) { Assert.Throws <ArgumentException>(() => { bsonBuffer.WriteCString((UTF8Encoding)Encoding.UTF8, "a\0b"); }); } }
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); }
// 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 }
internal override void WriteHeaderTo(BsonBuffer buffer) { base.WriteHeaderTo(buffer); buffer.WriteInt32(0); // reserved buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName); buffer.WriteInt32((int)_flags); }
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); } } }