/// <summary>
        /// Adds a secrets configuration source to the <paramref name="builder"/>, returning
        /// an <see cref="ISecretsConfigurationBuilder"/> used to define the source's secrets.
        /// </summary>
        /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
        /// <param name="configureSource">
        /// Configures the secrets configuration source. Can be <see langword="null"/>.
        /// </param>
        /// <returns>
        /// An <see cref="ISecretsConfigurationBuilder"/> used to define the source's secrets.
        /// </returns>
        public static ISecretsConfigurationBuilder AddRockLibSecrets(this IConfigurationBuilder builder,
                                                                     Action <SecretsConfigurationSource> configureSource)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var source = new SecretsConfigurationSource();

            configureSource?.Invoke(source);
            builder.Add(source);
            return(new SecretsConfigurationBuilder(source));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SecretsConfigurationProvider"/> class.
        /// </summary>
        /// <param name="source">The source settings.</param>
        public SecretsConfigurationProvider(SecretsConfigurationSource source)
        {
            Source  = source ?? throw new ArgumentNullException(nameof(source));
            Secrets = new ReadOnlyCollection <ISecret>(source.Secrets.ToArray());
            _timer  = new Timer(_ => Load());

            if (!Secrets.Any())
            {
                throw new ArgumentException("The SecretsConfigurationSource must contain at least one secret.", nameof(source));
            }
            if (Secrets.Any(s => s is null))
            {
                throw new ArgumentException("The SecretsConfigurationSource cannot contain any null secrets.", nameof(source));
            }
            if (Secrets.Any(s => s.ConfigurationKey is null))
            {
                throw new ArgumentException("The SecretsConfigurationSource cannot contain any secrets with a null Key.", nameof(source));
            }
            if (Secrets.Select(s => s.ConfigurationKey).Distinct(StringComparer.OrdinalIgnoreCase).Count() != Secrets.Count)
            {
                throw new ArgumentException("The SecretsConfigurationSource cannot contain any secrets with duplicate Keys.", nameof(source));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SecretsConfigurationBuilder"/> class.
 /// </summary>
 /// <param name="source"></param>
 public SecretsConfigurationBuilder(SecretsConfigurationSource source)
 {
     Source = source ?? throw new ArgumentNullException(nameof(source));
 }