当前位置: 首页>>代码示例>>C#>>正文


C# BsonBinaryWriter.PopMaxDocumentSize方法代码示例

本文整理汇总了C#中MongoDB.Bson.IO.BsonBinaryWriter.PopMaxDocumentSize方法的典型用法代码示例。如果您正苦于以下问题:C# BsonBinaryWriter.PopMaxDocumentSize方法的具体用法?C# BsonBinaryWriter.PopMaxDocumentSize怎么用?C# BsonBinaryWriter.PopMaxDocumentSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoDB.Bson.IO.BsonBinaryWriter的用法示例。


在下文中一共展示了BsonBinaryWriter.PopMaxDocumentSize方法的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();
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BulkDeleteOperation.cs

示例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();
     }
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:18,代码来源:MongoDeleteMessage.cs

示例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();
     }
 }
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:18,代码来源:MongoDeleteMessage.cs

示例4: 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;
                }
            }
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:41,代码来源:BulkInsertOperation.cs

示例5: 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();
            }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:22,代码来源:BulkUpdateOperation.cs

示例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;
        }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:33,代码来源:MongoInsertMessage.cs

示例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;
        }
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:33,代码来源:MongoInsertMessage.cs


注:本文中的MongoDB.Bson.IO.BsonBinaryWriter.PopMaxDocumentSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。