@@ -167,7 +167,10 @@ public async Task Invoke(HttpContext context)
167167 }
168168 }
169169
170- await this . options . OnParseCommands ? . Invoke ( new ImageCommandContext ( context , commands , CommandParser . Instance ) ) ;
170+ if ( this . options . OnParseCommands != null )
171+ {
172+ await this . options . OnParseCommands . Invoke ( new ImageCommandContext ( context , commands , CommandParser . Instance ) ) ;
173+ }
171174
172175 // Get the correct service for the request.
173176 IImageProvider provider = null ;
@@ -273,7 +276,11 @@ private async Task ProcessRequestAsync(HttpContext context, bool processRequest,
273276 using ( var image = FormattedImage . Load ( this . options . Configuration , inStream ) )
274277 {
275278 image . Process ( this . logger , this . processors , commands ) ;
276- await this . options . OnBeforeSave ? . Invoke ( image ) ;
279+ if ( this . options . OnBeforeSave != null )
280+ {
281+ await this . options . OnBeforeSave . Invoke ( image ) ;
282+ }
283+
277284 image . Save ( outStream ) ;
278285 format = image . Format ;
279286 }
@@ -298,7 +305,11 @@ private async Task ProcessRequestAsync(HttpContext context, bool processRequest,
298305 outStream . Position = 0 ;
299306 string contentType = cachedImageMetadata . ContentType ;
300307 string extension = this . formatUtilities . GetExtensionFromContentType ( contentType ) ;
301- await this . options . OnProcessed ? . Invoke ( new ImageProcessingContext ( context , outStream , commands , contentType , extension ) ) ;
308+ if ( this . options . OnProcessed != null )
309+ {
310+ await this . options . OnProcessed . Invoke ( new ImageProcessingContext ( context , outStream , commands , contentType , extension ) ) ;
311+ }
312+
302313 outStream . Position = 0 ;
303314
304315 // Save the image to the cache and send the response to the caller.
0 commit comments