Class CoreServiceBootstrapper
Provides dependency injection registration for all core CliniCore services. This bootstrapper ensures consistent service configuration across different client applications (CLI, GUI, etc.)
public static class CoreServiceBootstrapper
- Inheritance
-
CoreServiceBootstrapper
- Inherited Members
Methods
AddCliniCoreServices(IServiceCollection)
Registers all core CliniCore services with the dependency injection container. IMPORTANT: You must also register repositories separately using either:
- AddInMemoryRepositories() for standalone/testing
- AddRemoteRepositories(apiBaseUrl) for API-backed persistence Call this method from your client application's startup/configuration.
public static IServiceCollection AddCliniCoreServices(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection to register services with
Returns
- IServiceCollection
The service collection for chaining
AddCliniCoreServicesWithCustomAuth(IServiceCollection, IAuthenticationService)
Registers core services with custom implementations. Useful for testing or when you need to override default implementations.
public static IServiceCollection AddCliniCoreServicesWithCustomAuth(this IServiceCollection services, IAuthenticationService customAuthService)
Parameters
servicesIServiceCollectionThe service collection
customAuthServiceIAuthenticationServiceCustom authentication service implementation
Returns
- IServiceCollection
The service collection for chaining
AddCliniCoreServicesWithInMemory(IServiceCollection)
Registers all core CliniCore services WITH InMemory repositories. Use this for backwards compatibility or standalone operation.
public static IServiceCollection AddCliniCoreServicesWithInMemory(this IServiceCollection services)
Parameters
servicesIServiceCollection
Returns
EnsureApiAvailableAsync(string, bool, int)
Ensures the API server is available. If localProvider is true and the API is not running, attempts to start it as an independent background process.
public static Task<bool> EnsureApiAvailableAsync(string apiBaseUrl, bool localProvider, int timeoutSeconds = 30)
Parameters
apiBaseUrlstringThe base URL of the API (e.g., "http://localhost:5000")
localProviderboolIf true, will attempt to start API locally if not running
timeoutSecondsintHow long to wait for API to become healthy
Returns
IsApiHealthyAsync(string)
Checks if the API is responding to health check requests. Uses dedicated /health endpoint - lightweight, no database queries. Catches expected network exceptions by type to avoid debugger breaks.
public static Task<bool> IsApiHealthyAsync(string apiBaseUrl)
Parameters
apiBaseUrlstring