/// <summary> /// Adds a <see cref="HealthCheckRunner"/> with the specified name to the service collection. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/>.</param> /// <param name="name">The name of the health check runner to add.</param> /// <param name="configureOptions"> /// A delegate to configure the <see cref="IHealthCheckRunnerOptions"/> object that is used to create the /// <see cref="HealthCheckRunner"/>. /// </param> /// <returns>A new <see cref="IHealthCheckRunnerBuilder"/> for registering health checks.</returns> public static IHealthCheckRunnerBuilder AddHealthCheckRunner(this IServiceCollection services, string name, Action <IHealthCheckRunnerOptions> configureOptions = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } var builder = new HealthCheckRunnerBuilder(name, services, configureOptions); services.AddSingleton <IHealthCheckRunner>(builder.Build); return(builder); }
/// <summary> /// Adds a <see cref="HealthCheckRunner"/> with the specified name to the service collection. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/>.</param> /// <param name="name">The name of the health check runner to add.</param> /// <param name="configureOptions"> /// A delegate to configure the <see cref="IHealthCheckRunnerOptions"/> object that is used to create the /// <see cref="HealthCheckRunner"/>. /// </param> /// <param name="lifetime">The <see cref="ServiceLifetime"/> of the health check runner.</param> /// <returns>A new <see cref="IHealthCheckRunnerBuilder"/> for registering health checks.</returns> public static IHealthCheckRunnerBuilder AddHealthCheckRunner(this IServiceCollection services, string name, Action <IHealthCheckRunnerOptions> configureOptions = null, ServiceLifetime lifetime = _defaultLifetime) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } var builder = new HealthCheckRunnerBuilder(name, services, configureOptions); services.Add(new ServiceDescriptor(typeof(IHealthCheckRunner), builder.Build, lifetime)); return(builder); }