本文整理汇总了C#中MongoDB.Bson.IO.BsonBinaryWriter.PushMaxDocumentSize方法的典型用法代码示例。如果您正苦于以下问题:C# BsonBinaryWriter.PushMaxDocumentSize方法的具体用法?C# BsonBinaryWriter.PushMaxDocumentSize怎么用?C# BsonBinaryWriter.PushMaxDocumentSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Bson.IO.BsonBinaryWriter
的用法示例。
在下文中一共展示了BsonBinaryWriter.PushMaxDocumentSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeRequest
// 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();
}
示例2: WriteBodyTo
// 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();
}
}
示例3: WriteBodyTo
// 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();
}
}
示例4: SerializeRequest
// 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();
}
示例5: SerializeRequest
// 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;
}
}
示例6: AddRequest
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;
}
示例7: AddRequest
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;
}