| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | | using Azure.Core.Pipeline; |
| | 7 | | using Microsoft.Extensions.Options; |
| | 8 | |
|
| | 9 | | namespace Microsoft.Extensions.Azure |
| | 10 | | { |
| | 11 | | internal class DefaultClientOptionsSetup<T> : IConfigureNamedOptions<T> where T : class |
| | 12 | | { |
| | 13 | | private readonly IOptions<AzureClientsGlobalOptions> _defaultOptions; |
| | 14 | | private readonly IServiceProvider _serviceProvider; |
| | 15 | |
|
| 42 | 16 | | public DefaultClientOptionsSetup(IOptions<AzureClientsGlobalOptions> defaultOptions, IServiceProvider servicePro |
| | 17 | | { |
| 42 | 18 | | _defaultOptions = defaultOptions; |
| 42 | 19 | | _serviceProvider = serviceProvider; |
| 42 | 20 | | } |
| | 21 | |
|
| | 22 | | public void Configure(T options) |
| | 23 | | { |
| 42 | 24 | | if (options is ClientOptions clientOptions) |
| | 25 | | { |
| 96 | 26 | | foreach (var globalConfigureOption in _defaultOptions.Value.ConfigureOptionDelegates) |
| | 27 | | { |
| 6 | 28 | | globalConfigureOption(clientOptions, _serviceProvider); |
| | 29 | | } |
| | 30 | | } |
| 42 | 31 | | } |
| | 32 | |
|
| | 33 | | public void Configure(string name, T options) |
| | 34 | | { |
| 42 | 35 | | Configure(options); |
| 42 | 36 | | } |
| | 37 | | } |
| | 38 | | } |