/// <summary> /// Adds KeePass configuration source to the <code>builder</code>. /// </summary> /// <param name="builder">The configuration builder.</param> /// <param name="path">The path to the KeePass database file (KDBX).</param> /// <param name="compositeKey">The composite key used to unlock the KeePass database.</param> /// <param name="connection">The KeePass database connection.</param> /// <param name="filterEntries">Filter used to narrow the selection of entries loaded by the KeePass configuration provider.</param> /// <param name="resolveKey">The entry mapping to a string value used as the key in configuration lookups.</param> /// <param name="resolveValue">The entry mapping to a string value used as the value in configuration lookups.</param> /// <param name="provider">The file provider.</param> /// <param name="optional">if set to <c>true</c> [optional].</param> /// <param name="reloadOnChange">if set to <c>true</c> [reload on change].</param> /// <returns>The same <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder" />.</returns> public static IConfigurationBuilder AddKeePass( this IConfigurationBuilder builder, string path, CompositeKey compositeKey, IOConnectionInfo connection = null, Func <PwDatabase, IEnumerable <PwEntry> > filterEntries = null, Func <PwEntry, string> resolveKey = null, Func <string, PwEntry, string> resolveValue = null, IFileProvider provider = null, bool optional = false, bool reloadOnChange = false) { if (provider == null && Path.IsPathRooted(path)) { provider = new PhysicalFileProvider(Path.GetDirectoryName(path)); } connection = connection ?? new IOConnectionInfo { Path = path }; var source = new KeePassConfigurationSource() { Connection = connection, CompositeKey = compositeKey, FilterEntries = filterEntries, ResolveKey = resolveKey, ResolveValue = resolveValue, FileProvider = provider, Path = path, Optional = optional, ReloadOnChange = reloadOnChange }; return(builder.Add(source)); }
/// <summary> /// Initializes a new instance of the <see cref="KeePassConfigurationProvider" /> class. /// </summary> /// <param name="configurationSource">The configuration source.</param> public KeePassConfigurationProvider(KeePassConfigurationSource configurationSource) { _configurationSource = configurationSource; }