public static IServiceCollection AddAltitude3(this IServiceCollection services) { return(services .AddSingleton(provider => { AltitudeOptions altitudeOptions = provider.GetRequiredService <IOptions <AltitudeOptions> >().Value; return new HttpClient { BaseAddress = new Uri(altitudeOptions.SecurityApiBaseUrl) }; }) .AddScoped <ISecurityService, SecurityService>()); }
public SecurityService(IOptions <AltitudeOptions> altitudeOptions, HttpClient client) { _altitudeOptions = altitudeOptions?.Value ?? throw new ArgumentNullException(nameof(altitudeOptions)); _client = client ?? throw new ArgumentNullException(nameof(client)); }