Пример #1
0
        // methods
        private UpdateWireProtocol CreateProtocol()
        {
            var updateValidator = new UpdateOrReplacementElementNameValidator();

            return(new UpdateWireProtocol(
                       _collectionNamespace,
                       _messageEncoderSettings,
                       _writeConcern,
                       _criteria,
                       _update,
                       updateValidator,
                       _isMulti,
                       _isUpsert));
        }
        // methods
        private UpdateWireProtocol CreateProtocol()
        {
            var updateValidator = new UpdateOrReplacementElementNameValidator();

            return(new UpdateWireProtocol(
                       _collectionNamespace,
                       _messageEncoderSettings,
                       _writeConcern,
                       _request.Criteria,
                       _request.Update,
                       ElementNameValidatorFactory.ForUpdateType(_request.UpdateType),
                       _request.IsMulti,
                       _request.IsUpsert));
        }
        // methods
        protected override IWireProtocol <WriteConcernResult> CreateProtocol(IConnectionHandle connection, WriteRequest request)
        {
            var updateRequest   = (UpdateRequest)request;
            var updateValidator = new UpdateOrReplacementElementNameValidator();

            return(new UpdateWireProtocol(
                       CollectionNamespace,
                       MessageEncoderSettings,
                       WriteConcern,
                       updateRequest.Criteria,
                       updateRequest.Update,
                       updateValidator,
                       updateRequest.IsMultiUpdate ?? false,
                       updateRequest.IsUpsert ?? false));
        }
            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();
                }
            }