コード例 #1
0
        IAzureClientBuilder <TClient, TOptions> IAzureClientFactoryBuilderWithCredential.RegisterClientFactory <TClient, TOptions>(Func <TOptions, TokenCredential, TClient> clientFactory, bool requiresCredential)
        {
            var clientRegistration = new ClientRegistration <TClient>(DefaultClientName, (options, credential) => clientFactory((TOptions)options, credential));

            clientRegistration.RequiresTokenCredential = requiresCredential;

            _serviceCollection.AddSingleton(clientRegistration);

            _serviceCollection.TryAddSingleton(typeof(IConfigureOptions <AzureClientCredentialOptions <TClient> >), typeof(DefaultCredentialClientOptionsSetup <TClient>));
            _serviceCollection.TryAddSingleton(typeof(IOptionsMonitor <TOptions>), typeof(ClientOptionsMonitor <TClient, TOptions>));
            _serviceCollection.TryAddSingleton(typeof(ClientOptionsFactory <TClient, TOptions>), typeof(ClientOptionsFactory <TClient, TOptions>));
            _serviceCollection.TryAddSingleton(typeof(IAzureClientFactory <TClient>), typeof(AzureClientFactory <TClient, TOptions>));
            _serviceCollection.TryAddSingleton(
                typeof(TClient),
                provider => provider.GetService <IAzureClientFactory <TClient> >().CreateClient(DefaultClientName));

            return(new AzureClientBuilder <TClient, TOptions>(clientRegistration, _serviceCollection));
        }
コード例 #2
0
 internal AzureClientBuilder(ClientRegistration <TClient> clientRegistration, IServiceCollection serviceCollection)
 {
     Registration      = clientRegistration;
     ServiceCollection = serviceCollection;
 }
コード例 #3
0
 public ConfigureClientOptions(IServiceProvider serviceProvider, ClientRegistration <TClient, TOptions> registration, Action <TOptions, IServiceProvider> configureOptions)
 {
     _serviceProvider  = serviceProvider;
     _registration     = registration;
     _configureOptions = configureOptions;
 }