5
5
using Microsoft . Extensions . Configuration ;
6
6
using Microsoft . Extensions . FileProviders ;
7
7
8
+ /// <summary>
9
+ /// Extension methods for adding <see cref="SecureStoreConfigurationProvider"/>.
10
+ /// </summary>
8
11
public static class SecureStoreConfigurationExtensions
9
12
{
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>
10
22
public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , string path ,
11
23
string key , KeyType keyType )
12
24
{
13
25
return AddSecureStoreFile ( builder , path , key , keyType , false ) ;
14
26
}
15
27
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>
16
38
public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , string path ,
17
39
string key , KeyType keyType , bool optional )
18
40
{
19
41
return AddSecureStoreFile ( builder , path , key , keyType , optional , false ) ;
20
42
}
21
43
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>
22
55
public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder , string path ,
23
56
string key , KeyType keyType , bool optional ,
24
57
bool reloadOnChange )
25
58
{
26
59
return AddSecureStoreFile ( builder , null , path , key , keyType , optional , reloadOnChange ) ;
27
60
}
28
61
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>
29
74
public static IConfigurationBuilder AddSecureStoreFile ( this IConfigurationBuilder builder ,
30
75
IFileProvider provider ,
31
76
string path , string key , KeyType keyType , bool optional , bool reloadOnChange )
@@ -51,18 +96,24 @@ public static IConfigurationBuilder AddSecureStoreFile(this IConfigurationBuilde
51
96
path = Path . GetFileName ( path ) ;
52
97
}
53
98
54
- var source = new SecureStoreConfigurationSource
99
+ return builder . AddSecureStoreFile ( source =>
55
100
{
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
+ } ) ;
66
108
}
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 ) ;
67
118
}
68
119
}
0 commit comments