示例#1
0
        /// <summary>
        /// Configure an <see cref="ISecretProvider"/> in the application with a given set of stores configured in the given <paramref name="configureSecretStores"/>.
        /// </summary>
        /// <param name="services">The services to append the secret store configuration to.</param>
        /// <param name="configureSecretStores">The customization of the different target secret store sources to include in the final <see cref="ISecretProvider"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="services"/> or <paramref name="configureSecretStores"/> is <c>null</c>.</exception>
        public static IServiceCollection AddSecretStore(this IServiceCollection services, Action <SecretStoreBuilder> configureSecretStores)
        {
            Guard.NotNull(services, nameof(services), "Requires a set of services to add the secret store");
            Guard.NotNull(configureSecretStores, nameof(configureSecretStores), "Requires a function to register the secret providers in the secret store");

            var builder = new SecretStoreBuilder(services);

            configureSecretStores(builder);
            builder.RegisterSecretStore();

            return(services);
        }
        /// <summary>
        /// Configure an <see cref="ISecretProvider"/> in the application with a given set of stores configured in the given <paramref name="configureSecretStores"/>.
        /// </summary>
        /// <param name="functionsHostBuilder">The builder to append the secret store configuration to.</param>
        /// <param name="configureSecretStores">The customization of the different target secret store sources to include in the final <see cref="ISecretProvider"/>.</param>
        public static IFunctionsHostBuilder ConfigureSecretStore(this IFunctionsHostBuilder functionsHostBuilder, Action <SecretStoreBuilder> configureSecretStores)
        {
            Guard.NotNull(functionsHostBuilder, nameof(functionsHostBuilder));
            Guard.NotNull(configureSecretStores, nameof(configureSecretStores));

            var builder = new SecretStoreBuilder(functionsHostBuilder.Services);

            configureSecretStores(builder);
            builder.RegisterSecretStore();

            return(functionsHostBuilder);
        }