// 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();
                }
            }