55 using Microsoft . Extensions . Configuration ;
66 using Microsoft . Extensions . FileProviders ;
77
8+ /// <summary>
9+ /// Extension methods for adding <see cref="SecureStoreConfigurationProvider"/>.
10+ /// </summary>
811 public static class SecureStoreConfigurationExtensions
912 {
13+ /// <summary>
14+ /// Adds the SecureStore configuration provider at <paramref name="path"/> to <paramref name="builder"/>.
15+ /// </summary>
16+ /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
17+ /// <param name="path">Path relative to the base path stored in
18+ /// <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.</param>
19+ /// <param name="key">The SecureStore key.</param>
20+ /// <param name="keyType">The key type.</param>
21+ /// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
1022 public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , string path ,
1123 string key , KeyType keyType )
1224 {
1325 return AddSecureStoreFile ( builder , path , key , keyType , false ) ;
1426 }
1527
28+ /// <summary>
29+ /// Adds the SecureStore configuration provider at <paramref name="path"/> to <paramref name="builder"/>.
30+ /// </summary>
31+ /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
32+ /// <param name="path">Path relative to the base path stored in
33+ /// <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.</param>
34+ /// <param name="key">The SecureStore key.</param>
35+ /// <param name="keyType">The key type.</param>
36+ /// <param name="optional">Whether the file is optional.</param>
37+ /// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
1638 public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , string path ,
1739 string key , KeyType keyType , bool optional )
1840 {
1941 return AddSecureStoreFile ( builder , path , key , keyType , optional , false ) ;
2042 }
2143
44+ /// <summary>
45+ /// Adds the SecureStore configuration provider at <paramref name="path"/> to <paramref name="builder"/>.
46+ /// </summary>
47+ /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
48+ /// <param name="path">Path relative to the base path stored in
49+ /// <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.</param>
50+ /// <param name="key">The SecureStore key.</param>
51+ /// <param name="keyType">The key type.</param>
52+ /// <param name="optional">Whether the file is optional.</param>
53+ /// <param name="reloadOnChange">Whether the configuration should be reloaded if the file changes.</param>
54+ /// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
2255 public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , string path ,
2356 string key , KeyType keyType , bool optional ,
2457 bool reloadOnChange )
2558 {
2659 return AddSecureStoreFile ( builder , null , path , key , keyType , optional , reloadOnChange ) ;
2760 }
2861
62+ /// <summary>
63+ /// Adds a SecureStore configuration source to <paramref name="builder"/>.
64+ /// </summary>
65+ /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
66+ /// <param name="provider">The <see cref="IFileProvider"/> to use to access the file.</param>
67+ /// <param name="path">Path relative to the base path stored in
68+ /// <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.</param>
69+ /// <param name="key">The SecureStore key.</param>
70+ /// <param name="keyType">The key type.</param>
71+ /// <param name="optional">Whether the file is optional.</param>
72+ /// <param name="reloadOnChange">Whether the configuration should be reloaded if the file changes.</param>
73+ /// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
2974 public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder ,
3075 IFileProvider provider ,
3176 string path , string key , KeyType keyType , bool optional , bool reloadOnChange )
@@ -51,18 +96,24 @@ public static IConfigurationBuilder AddSecureStoreFile(this IConfigurationBuilde
5196 path = Path . GetFileName ( path ) ;
5297 }
5398
54- var source = new SecureStoreConfigurationSource
99+ return builder . AddSecureStoreFile ( source =>
55100 {
56- FileProvider = provider ,
57- Path = path ,
58- Key = key ,
59- KeyType = keyType ,
60- Optional = optional ,
61- ReloadOnChange = reloadOnChange
62- } ;
63-
64- builder . Add ( source ) ;
65- return builder ;
101+ source . FileProvider = provider ;
102+ source . Path = path ;
103+ source . Key = key ;
104+ source . KeyType = keyType ;
105+ source . Optional = optional ;
106+ source . ReloadOnChange = reloadOnChange ;
107+ } ) ;
66108 }
109+
110+ /// <summary>
111+ /// Adds a SecureStore configuration source to <paramref name="builder"/>.
112+ /// </summary>
113+ /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
114+ /// <param name="configureSource">Configures the source.</param>
115+ /// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
116+ public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , Action < SecureStoreConfigurationSource > configureSource )
117+ => builder . Add ( configureSource ) ;
67118 }
68119}
0 commit comments