| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | | using Microsoft.Extensions.Options; |
| | 7 | |
|
| | 8 | | namespace Microsoft.Extensions.Azure |
| | 9 | | { |
| | 10 | | internal class ConfigureClientCredentials<TClient, TOptions> : IConfigureNamedOptions<AzureClientCredentialOptions<T |
| | 11 | | { |
| | 12 | | private readonly ClientRegistration<TClient, TOptions> _registration; |
| | 13 | | private readonly Func<IServiceProvider, TokenCredential> _credentialFactory; |
| | 14 | |
|
| 6 | 15 | | public ConfigureClientCredentials( |
| 6 | 16 | | ClientRegistration<TClient, TOptions> registration, |
| 6 | 17 | | Func<IServiceProvider, TokenCredential> credentialFactory) |
| | 18 | | { |
| 6 | 19 | | _registration = registration; |
| 6 | 20 | | _credentialFactory = credentialFactory; |
| 6 | 21 | | } |
| | 22 | |
|
| | 23 | | public void Configure(AzureClientCredentialOptions<TClient> options) |
| | 24 | | { |
| 0 | 25 | | } |
| | 26 | |
|
| | 27 | | public void Configure(string name, AzureClientCredentialOptions<TClient> options) |
| | 28 | | { |
| 6 | 29 | | if (name == _registration.Name) |
| | 30 | | { |
| 6 | 31 | | options.CredentialFactory = _credentialFactory; |
| | 32 | | } |
| 6 | 33 | | } |
| | 34 | | } |
| | 35 | | } |