/// <summary> /// Add the Azure implementation of leasing to the service collection. /// </summary> /// <param name="services">The service collection to which to add azure leasing.</param> /// <param name="options">The configuration options.</param> /// <param name="configureLeasing">An optional configuration function for leasing.</param> /// <returns>The service collection.</returns> public static IServiceCollection AddAzureLeasing( this IServiceCollection services, AzureLeaseProviderOptions options, Action <AzureLeaseProvider>?configureLeasing = null) { return(services.AddAzureLeasing(_ => options, configureLeasing)); }
public static void SetupFeature(FeatureContext featureContext) { ContainerBindings.ConfigureServices( featureContext, serviceCollection => { var fallbackSettings = new Dictionary <string, string> { { "STORAGEACCOUNTCONNECTIONSTRING", "UseDevelopmentStorage=true" }, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddConfigurationForTest(null, fallbackSettings); IConfigurationRoot config = configurationBuilder.Build(); serviceCollection.AddSingleton(config); var options = new AzureLeaseProviderOptions { StorageAccountConnectionString = config["STORAGEACCOUNTCONNECTIONSTRING"], }; serviceCollection.AddTestNameProvider(); serviceCollection.AddAzureLeasing(options); }); }
/// <summary> /// Initializes a new instance of the <see cref="AzureLeaseProvider"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="options">The configuration options.</param> /// <param name="nameProvider">The name provider service.</param> public AzureLeaseProvider(ILogger <ILeaseProvider> logger, AzureLeaseProviderOptions options, INameProvider nameProvider) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.options = options ?? throw new ArgumentNullException(nameof(options)); this.nameProvider = nameProvider ?? throw new ArgumentNullException(nameof(nameProvider)); }