@@ -387,6 +387,18 @@ public ConfigBuilder WithCertificateTrustRule(
387387 return WithCertificateTrustRule ( certificateTrustRule , certs ) ;
388388 }
389389
390+ /// <summary>Disable all notifications for the lifetime of the driver.</summary>
391+ /// <remarks>Cannot be used with: <see cref="WithNotifications(Severity?, Category[], Classification[])"/>.</remarks>
392+ /// <returns>A <see cref="ConfigBuilder"/> instance for further configuration options.</returns>
393+ /// <seealso cref="WithNotifications(Severity?, Category[], Classification[])"/>
394+ /// <seealso cref="SessionConfigBuilder.WithNotifications(Severity?, Category[], Classification[])"/>
395+ /// <seealso cref="SessionConfigBuilder.WithNotificationsDisabled"/>
396+ public ConfigBuilder WithNotificationsDisabled ( )
397+ {
398+ _config . NotificationsConfig = new NotificationsDisabledConfig ( ) ;
399+ return this ;
400+ }
401+
390402 /// <summary>
391403 /// Override configuration for which <see cref="INotification"/>s should be emitted for the lifetime of the
392404 /// driver. <br/> Unspecified configuration will be provided by configuration in the server. <br/> Disabling categories or
@@ -402,82 +414,38 @@ public ConfigBuilder WithCertificateTrustRule(
402414 /// an empty collection, all categories are enabled.<br/> By leaving null, the value will inherit configuration from the
403415 /// server.
404416 /// </param>
405- /// <exception cref="ArgumentException">Thrown when both parameters are null.</exception>
417+ /// <param name="disabledClassifications">
418+ /// Optional parameter to override the classification of notifications emitted. <br/> By passing
419+ /// an empty collection, all classifications are enabled.<br/> By leaving null, the value will inherit configuration from the
420+ /// server.
421+ /// </param>
422+ /// <exception cref="ArgumentException">Thrown when all parameters are null.</exception>
406423 /// <returns>A <see cref="ConfigBuilder"/> instance for further configuration options.</returns>
407424 /// <seealso cref="WithNotificationsDisabled"/>
408- /// <seealso cref="SessionConfigBuilder.WithNotifications(Severity?, Category[])"/>"/>
425+ /// <seealso cref="SessionConfigBuilder.WithNotifications(Severity?, Category[], Classification[] )"/>"/>
409426 /// <seealso cref="SessionConfigBuilder.WithNotificationsDisabled"/>
410427 /// <returns>A <see cref="ConfigBuilder"/> instance for further configuration options.</returns>
411428 public ConfigBuilder WithNotifications (
412429 Severity ? minimumSeverity ,
413- Category [ ] disabledCategories )
430+ Category [ ] disabledCategories = null ,
431+ Classification [ ] disabledClassifications = null )
414432 {
415- if ( minimumSeverity == null && disabledCategories == null )
433+ if ( minimumSeverity == null && disabledCategories == null && disabledClassifications == null )
416434 {
417435 throw new ArgumentException (
418- $ "Both { nameof ( minimumSeverity ) } and { nameof ( disabledCategories ) } are both null, at least one must be non-null.") ;
436+ $ "All { nameof ( minimumSeverity ) } , { nameof ( disabledCategories ) } and { nameof ( disabledClassifications ) } " +
437+ "are null, at least one must be non-null." ) ;
419438 }
420439
421- _config . NotificationsConfig = new NotificationsConfig ( minimumSeverity , disabledCategories ) ;
422- return this ;
423- }
424-
425- /// <summary>Disable all notifications for the lifetime of the driver.</summary>
426- /// <remarks>Cannot be used with: <see cref="WithNotifications(Severity?, Category[])"/>.</remarks>
427- /// <returns>A <see cref="ConfigBuilder"/> instance for further configuration options.</returns>
428- /// <seealso cref="WithNotifications(Severity?, Category[])"/>
429- /// <seealso cref="SessionConfigBuilder.WithNotifications(Severity?, Category[])"/>
430- /// <seealso cref="SessionConfigBuilder.WithNotificationsDisabled"/>
431- public ConfigBuilder WithNotificationsDisabled ( )
432- {
433- _config . NotificationsConfig = new NotificationsDisabledConfig ( ) ;
434- return this ;
435- }
436-
437-
438- /// <summary>
439- /// This is a preview API, This API may change between minor revisions.<br/>
440- ///
441- /// Override configuration for which <see cref="IGqlStatusObject"/> and <see cref="INotification"/> should be emitted
442- /// for the lifetime of the session. <br/> Unspecified configuration will be provided by configuration specified in
443- /// the server or the driver's <see cref="ConfigBuilder.WithNotifications(Severity?, Classification[])"/> or
444- /// <see cref="ConfigBuilder.WithNotifications(Severity?, Category[])"/>. <br/> If the driver has disabled
445- /// notifications with <see cref="ConfigBuilder.WithNotificationsDisabled"/>, the unspecified values will be
446- /// provided by the server. <br/> Disabling categories, classifications or severities allows the server to skip
447- /// analysis for those which can speed up query execution.
448- /// </summary>
449- /// <remarks>Cannot be used with: <see cref="WithNotificationsDisabled"/> or
450- /// <see cref="WithNotifications(Severity?, Category[])"/>.</remarks>
451- /// <param name="minimumSeverity">
452- /// Optional parameter to override the minimum severity of notifications emitted. <br/> By
453- /// leaving null, the value will inherit configuration of <see cref="Config.NotificationsConfig"/> or the server.
454- /// </param>
455- /// <param name="disabledClassifications">
456- /// Optional parameter to override the category of notifications and classifications of GQL Statuses emitted. <br/>
457- /// By passing an empty collection, all categories are enabled.<br/> By leaving null, the value will inherit
458- /// configuration from <see cref="Config.NotificationsConfig"/> or the server.
459- /// </param>
460- /// <exception cref="ArgumentException">Thrown when both parameters are null.</exception>
461- /// <returns>A <see cref="SessionConfigBuilder"/> instance for further configuration options.</returns>
462- /// <seealso cref="WithNotificationsDisabled"/>
463- /// <seealso cref="WithNotifications(Severity?, Category[])"/>
464- /// <seealso cref="ConfigBuilder.WithNotifications(Severity?, Category[])"/>
465- /// <seealso cref="ConfigBuilder.WithNotifications(Severity?, Classification[])"/>
466- /// <seealso cref="ConfigBuilder.WithNotificationsDisabled"/>
467- /// <since>5.23.0</since>
468- [ Obsolete ( "This is a Preview API and may change between minor versions. Obsolete will be removed in a later revision." ) ]
469- public ConfigBuilder WithNotifications (
470- Severity ? minimumSeverity ,
471- Classification [ ] disabledClassifications )
472- {
473- if ( minimumSeverity == null && disabledClassifications == null )
440+ Category [ ] categoriesToDisable = null ;
441+ if ( disabledCategories != null || disabledClassifications != null )
474442 {
475- throw new ArgumentException (
476- $ "Both { nameof ( minimumSeverity ) } and { nameof ( disabledClassifications ) } are both null, at least one must be non-null." ) ;
443+ var classificationsAsCategories = disabledClassifications ? . Select ( x => ( Category ) ( int ) x ) ?? [ ] ;
444+ categoriesToDisable = ( disabledCategories ?? [ ] ) . Concat ( classificationsAsCategories ) . ToArray ( ) ;
477445 }
478446
479- _config . NotificationsConfig = new NotificationsConfig ( minimumSeverity ,
480- disabledClassifications . Select ( x => ( Category ) ( int ) x ) . ToArray ( ) ) ;
447+ _config . NotificationsConfig = new NotificationsConfig ( minimumSeverity , categoriesToDisable ) ;
448+
481449 return this ;
482450 }
483451
0 commit comments