@@ -32,18 +32,20 @@ public class IngressCache : ICache
3232
3333 public IngressCache ( IOptions < YarpOptions > options , IServerCertificateSelector certificateSelector , ICertificateHelper certificateHelper , ILogger < IngressCache > logger )
3434 {
35- _options = options ? . Value ?? throw new ArgumentNullException ( nameof ( options ) ) ;
36- _certificateSelector = certificateSelector ?? throw new ArgumentNullException ( nameof ( certificateSelector ) ) ;
37- _certificateHelper = certificateHelper ?? throw new ArgumentNullException ( nameof ( certificateHelper ) ) ;
38- _logger = logger ?? throw new ArgumentNullException ( nameof ( logger ) ) ;
35+ ArgumentNullException . ThrowIfNull ( options ? . Value ) ;
36+ ArgumentNullException . ThrowIfNull ( certificateSelector ) ;
37+ ArgumentNullException . ThrowIfNull ( certificateHelper ) ;
38+ ArgumentNullException . ThrowIfNull ( logger ) ;
39+
40+ _options = options . Value ;
41+ _certificateSelector = certificateSelector ;
42+ _certificateHelper = certificateHelper ;
43+ _logger = logger ;
3944 }
4045
4146 public void Update ( WatchEventType eventType , V1IngressClass ingressClass )
4247 {
43- if ( ingressClass is null )
44- {
45- throw new ArgumentNullException ( nameof ( ingressClass ) ) ;
46- }
48+ ArgumentNullException . ThrowIfNull ( ingressClass ) ;
4749
4850 if ( ! string . Equals ( _options . ControllerClass , ingressClass . Spec . Controller , StringComparison . OrdinalIgnoreCase ) )
4951 {
@@ -72,10 +74,7 @@ public void Update(WatchEventType eventType, V1IngressClass ingressClass)
7274
7375 public bool Update ( WatchEventType eventType , V1Ingress ingress )
7476 {
75- if ( ingress is null )
76- {
77- throw new ArgumentNullException ( nameof ( ingress ) ) ;
78- }
77+ ArgumentNullException . ThrowIfNull ( ingress ) ;
7978
8079 Namespace ( ingress . Namespace ( ) ) . Update ( eventType , ingress ) ;
8180 return true ;
@@ -84,10 +83,7 @@ public bool Update(WatchEventType eventType, V1Ingress ingress)
8483
8584 public ImmutableList < string > Update ( WatchEventType eventType , V1Service service )
8685 {
87- if ( service is null )
88- {
89- throw new ArgumentNullException ( nameof ( service ) ) ;
90- }
86+ ArgumentNullException . ThrowIfNull ( service ) ;
9187
9288 return Namespace ( service . Namespace ( ) ) . Update ( eventType , service ) ;
9389 }
0 commit comments