@@ -29,28 +29,32 @@ public static class IHealthChecksBuilderExtensions
2929 /// Configures health check for the MONAI Deploy Storage Service.
3030 /// </summary>
3131 /// <param name="builder">Instance of <see cref="IHealthChecksBuilder"/>.</param>
32+ /// <param name="serviceCollection">Instance of <see cref="IServiceCollection"/>.</param>
3233 /// <param name="serviceProvider">Instance of <see cref="IServiceProvider"/>.</param>
3334 /// <param name="fullyQualifiedTypeName">Fully qualified type name of the service to use.</param>
3435 /// <returns>Instance of <see cref="IHealthChecksBuilder"/>.</returns>
3536 /// <exception cref="ConfigurationException"></exception>
3637 public static IHealthChecksBuilder AddMonaiDeployStorageHealthCheck (
3738 this IHealthChecksBuilder builder ,
39+ IServiceCollection serviceCollection ,
3840 string fullyQualifiedTypeName ,
3941 HealthStatus ? failureStatus = null ,
4042 IEnumerable < string > ? tags = null ,
4143 TimeSpan ? timeout = null )
42- => AddMonaiDeployStorageHealthCheck ( builder , fullyQualifiedTypeName , new FileSystem ( ) , failureStatus , tags , timeout ) ;
44+ => AddMonaiDeployStorageHealthCheck ( builder , serviceCollection , fullyQualifiedTypeName , new FileSystem ( ) , failureStatus , tags , timeout ) ;
4345
4446 /// <summary>
4547 /// Configures health check for the MONAI Deploy Storage Service.
4648 /// </summary>
4749 /// <param name="builder">Instance of <see cref="IHealthChecksBuilder"/>.</param>
50+ /// <param name="serviceCollection">Instance of <see cref="IServiceCollection"/>.</param>
4851 /// <param name="fullyQualifiedTypeName">Fully qualified type name of the service to use.</param>
4952 /// <param name="fileSystem">Instance of <see cref="IFileSystem"/>.</param>
5053 /// <returns>Instance of <see cref="IHealthChecksBuilder"/>.</returns>
5154 /// <exception cref="ConfigurationException"></exception>
5255 public static IHealthChecksBuilder AddMonaiDeployStorageHealthCheck (
5356 this IHealthChecksBuilder builder ,
57+ IServiceCollection serviceCollection ,
5458 string fullyQualifiedTypeName ,
5559 IFileSystem fileSystem ,
5660 HealthStatus ? failureStatus = null ,
@@ -68,18 +72,25 @@ public static IHealthChecksBuilder AddMonaiDeployStorageHealthCheck(
6872 AppDomain . CurrentDomain . AssemblyResolve += resolveEventHandler ;
6973
7074 var storageServiceAssembly = IServiceCollectionExtensions . LoadAssemblyFromDisk ( IServiceCollectionExtensions . GetAssemblyName ( fullyQualifiedTypeName ) , fileSystem ) ;
71- var serviceRegistrationType = storageServiceAssembly . GetTypes ( ) . FirstOrDefault ( p => p . IsSubclassOf ( typeof ( HealthCheckRegistrationBase ) ) ) ;
75+ var healthCheckBase = storageServiceAssembly . GetTypes ( ) . FirstOrDefault ( p => p . IsSubclassOf ( typeof ( HealthCheckRegistrationBase ) ) ) ;
7276
73- if ( serviceRegistrationType is null || Activator . CreateInstance ( serviceRegistrationType , fullyQualifiedTypeName ) is not HealthCheckRegistrationBase healthCheckBuilder )
77+ if ( healthCheckBase is null || Activator . CreateInstance ( healthCheckBase , fullyQualifiedTypeName ) is not HealthCheckRegistrationBase healthCheckBuilder )
7478 {
7579 throw new ConfigurationException ( $ "Service registrar cannot be found for the configured plug-in '{ fullyQualifiedTypeName } '.") ;
7680 }
81+ var serviceRegistrationType = storageServiceAssembly . GetTypes ( ) . FirstOrDefault ( p => p . IsSubclassOf ( typeof ( ServiceRegistrationBase ) ) ) ;
7782
83+ if ( serviceRegistrationType is null || Activator . CreateInstance ( serviceRegistrationType , fullyQualifiedTypeName ) is not ServiceRegistrationBase serviceRegistrar )
84+ {
85+ throw new ConfigurationException ( $ "Service registrar cannot be found for the configured plug-in '{ fullyQualifiedTypeName } '.") ;
86+ }
7887 if ( ! IServiceCollectionExtensions . IsSupportedType ( fullyQualifiedTypeName , storageServiceAssembly ) )
7988 {
8089 throw new ConfigurationException ( $ "The configured type '{ fullyQualifiedTypeName } ' does not implement the { typeof ( IStorageService ) . Name } interface.") ;
8190 }
8291
92+ serviceRegistrar . Configure ( serviceCollection ) ;
93+
8394 healthCheckBuilder . Configure ( builder , failureStatus , tags , timeout ) ;
8495
8596 AppDomain . CurrentDomain . AssemblyResolve -= resolveEventHandler ;
0 commit comments