Skip to content

Commit

Permalink
Add support for configuration via unnamed options
Browse files Browse the repository at this point in the history
  • Loading branch information
rickykaare committed Jun 27, 2024
1 parent 7efdb7f commit c3695f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Cabazure.Client/ClientInitializationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ internal static IServiceCollection AddCabazureClient<TOptions>(
if (clientOptions != null)
{
services
.AddOptions<TOptions>(clientName)
.AddOptions<TOptions>()
.Configure(clientOptions);
}
void ConfigureHttpClient(IServiceProvider services, HttpClient client)
=> client.BaseAddress = services
.GetRequiredService<IOptionsMonitor<TOptions>>()
.Get(clientName)
.GetRequiredService<IOptions<TOptions>>()
.Value
.GetBaseAddress();
void ConfigureAuthHandler(IList<DelegatingHandler> handlers, IServiceProvider services)
{
var options = services
.GetRequiredService<IOptionsMonitor<TOptions>>()
.Get(clientName);
.GetRequiredService<IOptions<TOptions>>()
.Value;
if (options is ICabazureAuthClientOptions authOptions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ internal static IServiceCollection AddCabazureClient<TOptions>(
if (clientOptions != null)
{
services
.AddOptions<TOptions>(clientName)
.AddOptions<TOptions>()
.Configure(clientOptions);
}

void ConfigureHttpClient(IServiceProvider services, HttpClient client)
=> client.BaseAddress = services
.GetRequiredService<IOptionsMonitor<TOptions>>()
.Get(clientName)
.GetRequiredService<IOptions<TOptions>>()
.Value
.GetBaseAddress();

void ConfigureAuthHandler(IList<DelegatingHandler> handlers, IServiceProvider services)
{
var options = services
.GetRequiredService<IOptionsMonitor<TOptions>>()
.Get(clientName);
.GetRequiredService<IOptions<TOptions>>()
.Value;

if (options is ICabazureAuthClientOptions authOptions)
{
Expand Down

0 comments on commit c3695f4

Please sign in to comment.