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


C# BsonBinaryWriter.PushElementNameValidator方法代码示例

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


在下文中一共展示了BsonBinaryWriter.PushElementNameValidator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestInvalidKeys

        public void TestInvalidKeys(string key)
        {
            var c = new C { Id = 1, D = new Hashtable { { key, 2 } }, G = new Dictionary<object, int> { { key, 3 } } };

            using (var stream = new MemoryStream())
            using (var bsonWriter = new BsonBinaryWriter(stream, BsonBinaryWriterSettings.Defaults))
            {
                bsonWriter.PushElementNameValidator(CollectionElementNameValidator.Instance);
                Assert.Throws<BsonSerializationException>(() => BsonSerializer.Serialize(bsonWriter, c));
            }
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:11,代码来源:CSharp624Tests.cs

示例2: WriteUpdate

 private void WriteUpdate(BsonBinaryWriter binaryWriter, BsonDocument update, IElementNameValidator updateValidator)
 {
     binaryWriter.PushElementNameValidator(updateValidator);
     try
     {
         var position = binaryWriter.BaseStream.Position;
         var context = BsonSerializationContext.CreateRoot(binaryWriter);
         BsonDocumentSerializer.Instance.Serialize(context, update);
         if (updateValidator is UpdateElementNameValidator && binaryWriter.BaseStream.Position == position + 5)
         {
             throw new BsonSerializationException("Update documents cannot be empty.");
         }
     }
     finally
     {
         binaryWriter.PopElementNameValidator();
     }
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:18,代码来源:UpdateMessageBinaryEncoder.cs

示例3: SerializeUpdate

            private void SerializeUpdate(BsonBinaryWriter bsonWriter, BsonDocument update)
            {
                var updateValidator = new UpdateOrReplacementElementNameValidator();

                bsonWriter.PushElementNameValidator(updateValidator);
                try
                {
                    var context = BsonSerializationContext.CreateRoot<BsonDocument>(bsonWriter);
                    BsonDocumentSerializer.Instance.Serialize(context, update);
                }
                finally
                {
                    bsonWriter.PopElementNameValidator();
                }
            }
开发者ID:rmattos,项目名称:mongo-csharp-driver,代码行数:15,代码来源:BulkUpdateOperation.cs

示例4: WriteQuery

 private void WriteQuery(BsonBinaryWriter binaryWriter, BsonDocument query, IElementNameValidator queryValidator)
 {
     binaryWriter.PushElementNameValidator(queryValidator);
     try
     {
         var context = BsonSerializationContext.CreateRoot(binaryWriter);
         BsonDocumentSerializer.Instance.Serialize(context, query ?? new BsonDocument());
     }
     finally
     {
         binaryWriter.PopElementNameValidator();
     }
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:13,代码来源:QueryMessageBinaryEncoder.cs

示例5: SerializeUpdate

 private void SerializeUpdate(BsonBinaryWriter bsonWriter, BsonDocument update, UpdateType updateType)
 {
     bsonWriter.PushElementNameValidator(ElementNameValidatorFactory.ForUpdateType(updateType));
     try
     {
         var position = bsonWriter.BaseStream.Position;
         var context = BsonSerializationContext.CreateRoot(bsonWriter);
         BsonDocumentSerializer.Instance.Serialize(context, update);
         if (updateType == UpdateType.Update && bsonWriter.BaseStream.Position == position + 8)
         {
             throw new BsonSerializationException("Update documents cannot be empty.");
         }
     }
     finally
     {
         bsonWriter.PopElementNameValidator();
     }
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:18,代码来源:BulkUpdateOperation.cs

示例6: SerializeUpdate

 private void SerializeUpdate(BsonBinaryWriter bsonWriter, BsonDocument update, UpdateType updateType)
 {
     bsonWriter.PushElementNameValidator(ElementNameValidatorFactory.ForUpdateType(updateType));
     try
     {
         var context = BsonSerializationContext.CreateRoot<BsonDocument>(bsonWriter);
         BsonDocumentSerializer.Instance.Serialize(context, update);
     }
     finally
     {
         bsonWriter.PopElementNameValidator();
     }
 }
开发者ID:bollinim,项目名称:mongo-csharp-driver,代码行数:13,代码来源:BulkUpdateOperation.cs


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