public PushMaxDocumentSize ( int maxDocumentSize ) : void | ||
maxDocumentSize | int | The maximum size of the document. |
return | void |
// protected methods protected override void SerializeRequest(BsonBinaryWriter bsonWriter, WriteRequest request) { var deleteRequest = (DeleteRequest)request; bsonWriter.PushMaxDocumentSize(MaxDocumentSize); bsonWriter.WriteStartDocument(); bsonWriter.WriteName("q"); BsonSerializer.Serialize(bsonWriter, deleteRequest.Query ?? new QueryDocument()); bsonWriter.WriteInt32("limit", deleteRequest.Limit); bsonWriter.WriteEndDocument(); bsonWriter.PopMaxDocumentSize(); }
// internal methods internal override void WriteBodyTo(BsonStreamWriter streamWriter) { using (var bsonWriter = new BsonBinaryWriter(streamWriter.BaseStream, WriterSettings)) { bsonWriter.PushMaxDocumentSize(_maxDocumentSize); if (_query == null) { bsonWriter.WriteStartDocument(); bsonWriter.WriteEndDocument(); } else { BsonSerializer.Serialize(bsonWriter, _query.GetType(), _query, b => b.SerializeIdFirst = true); } bsonWriter.PopMaxDocumentSize(); } }
// internal methods internal override void WriteBodyTo(BsonBuffer buffer) { using (var bsonWriter = new BsonBinaryWriter(buffer, false, WriterSettings)) { bsonWriter.PushMaxDocumentSize(_maxDocumentSize); if (_query == null) { bsonWriter.WriteStartDocument(); bsonWriter.WriteEndDocument(); } else { BsonSerializer.Serialize(bsonWriter, _query.GetType(), _query, DocumentSerializationOptions.SerializeIdFirstInstance); } bsonWriter.PopMaxDocumentSize(); } }
// protected methods protected override void SerializeRequest(BsonBinaryWriter bsonWriter, WriteRequest request) { var updateRequest = (UpdateRequest)request; bsonWriter.PushMaxDocumentSize(MaxWireDocumentSize); bsonWriter.WriteStartDocument(); bsonWriter.WriteName("q"); BsonSerializer.Serialize(bsonWriter, updateRequest.Query ?? new QueryDocument()); bsonWriter.WriteName("u"); BsonSerializer.Serialize(bsonWriter, updateRequest.Update); if (updateRequest.IsMultiUpdate.HasValue) { bsonWriter.WriteBoolean("multi", updateRequest.IsMultiUpdate.Value); } if (updateRequest.IsUpsert.HasValue) { bsonWriter.WriteBoolean("upsert", updateRequest.IsUpsert.Value); } bsonWriter.WriteEndDocument(); bsonWriter.PopMaxDocumentSize(); }
// protected methods protected override void SerializeRequest(BsonBinaryWriter bsonWriter, WriteRequest request) { var insertRequest = (InsertRequest)request; var document = insertRequest.Document; if (document == null) { throw new ArgumentException("Batch contains one or more null documents."); } var actualType = document.GetType(); IBsonSerializer serializer; if (actualType == insertRequest.NominalType && insertRequest.Serializer != null) { serializer = insertRequest.Serializer; } else { if (_cachedSerializerType != actualType) { _cachedSerializer = BsonSerializer.LookupSerializer(actualType); _cachedSerializerType = actualType; } serializer = _cachedSerializer; } var serializationOptions = insertRequest.SerializationOptions ?? DocumentSerializationOptions.SerializeIdFirstInstance; var savedCheckElementNames = bsonWriter.CheckElementNames; try { bsonWriter.PushMaxDocumentSize(MaxDocumentSize); bsonWriter.CheckElementNames = _checkElementNames; serializer.Serialize(bsonWriter, insertRequest.NominalType, document, serializationOptions); } finally { bsonWriter.PopMaxDocumentSize(); bsonWriter.CheckElementNames = savedCheckElementNames; } }
private void AddRequest(BsonStreamWriter streamWriter, InsertRequest request) { var document = request.Document; if (document == null) { throw new ArgumentException("Batch contains one or more null documents."); } var serializer = request.Serializer; if (serializer == null) { var nominalType = request.NominalType; if (_cachedSerializerType != nominalType) { _cachedSerializer = BsonSerializer.LookupSerializer(nominalType); _cachedSerializerType = nominalType; } serializer = _cachedSerializer; } _lastDocumentStartPosition = (int)streamWriter.Position; using (var bsonWriter = new BsonBinaryWriter(streamWriter.BaseStream, WriterSettings)) { bsonWriter.PushMaxDocumentSize(_maxDocumentSize); bsonWriter.CheckElementNames = _checkElementNames; var context = BsonSerializationContext.CreateRoot(bsonWriter, request.NominalType, c => c.SerializeIdFirst = true); serializer.Serialize(context, document); bsonWriter.PopMaxDocumentSize(); } _batchCount++; _batchLength = (int)streamWriter.Position - _batchStartPosition; }
private void AddRequest(BsonBuffer buffer, InsertRequest request) { var document = request.Document; if (document == null) { throw new ArgumentException("Batch contains one or more null documents."); } var serializer = request.Serializer; if (serializer == null) { var actualType = document.GetType(); if (_cachedSerializerType != actualType) { _cachedSerializer = BsonSerializer.LookupSerializer(actualType); _cachedSerializerType = actualType; } serializer = _cachedSerializer; } var serializationOptions = request.SerializationOptions ?? DocumentSerializationOptions.SerializeIdFirstInstance; _lastDocumentStartPosition = buffer.Position; using (var bsonWriter = new BsonBinaryWriter(buffer, false, WriterSettings)) { bsonWriter.PushMaxDocumentSize(_maxDocumentSize); bsonWriter.CheckElementNames = _checkElementNames; serializer.Serialize(bsonWriter, request.NominalType, document, serializationOptions); bsonWriter.PopMaxDocumentSize(); } _batchCount++; _batchLength = buffer.Position - _batchStartPosition; }