Skip to content

Commit b28851b

Browse files
committed
Added Xml docs. Removing pre-release tag.
1 parent 2244375 commit b28851b

File tree

6 files changed

+101
-13
lines changed

6 files changed

+101
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SecureStore.Contrib.Configuration
22

33
[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/SecureStore.Contrib.Configuration?color=blue)](https://www.nuget.org/packages/SecureStore.Contrib.Configuration)
4+
[![Nuget](https://img.shields.io/nuget/dt/SecureStore.Contrib.Configuration?color=blue)](https://www.nuget.org/packages/SecureStore.Contrib.Configuration)
45
![build](https://github.com/gowon/SecureStore.Contrib.Configuration/workflows/build/badge.svg)
56
[![codecov](https://codecov.io/gh/gowon/SecureStore.Contrib.Configuration/branch/master/graph/badge.svg)](https://codecov.io/gh/gowon/SecureStore.Contrib.Configuration)
67

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
namespace SecureStore.Contrib.Configuration
22
{
3+
/// <summary>
4+
/// SecureStore key types.
5+
/// </summary>
36
public enum KeyType
47
{
8+
/// <summary>
9+
/// File key.
10+
/// </summary>
511
File,
12+
13+
/// <summary>
14+
/// Password key.
15+
/// </summary>
616
Password
717
}
818
}

src/SecureStore.Contrib.Configuration/SecureStore.Contrib.Configuration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<NoWarn>$(NoWarn);1591</NoWarn>
7-
<Version>1.0.0-alpha</Version>
7+
<Version>1.0.0</Version>
88
<Authors>Gowon Patterson</Authors>
99
<Description>A SecureStore configuration provider to use with Microsoft.Extensions.Configuration.</Description>
1010
<Copyright>© Gowon Patterson. All rights reserved.</Copyright>

src/SecureStore.Contrib.Configuration/SecureStoreConfigurationExtensions.cs

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,72 @@
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
}

src/SecureStore.Contrib.Configuration/SecureStoreConfigurationProvider.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@
66
using Microsoft.Extensions.Configuration;
77
using NeoSmart.SecureStore;
88

9+
/// <summary>
10+
/// A SecureStore file based <see cref="FileConfigurationProvider"/>.
11+
/// </summary>
912
public class SecureStoreConfigurationProvider : FileConfigurationProvider
1013
{
14+
/// <summary>
15+
/// Initializes a new instance with the specified source.
16+
/// </summary>
17+
/// <param name="source">The source settings.</param>
1118
public SecureStoreConfigurationProvider(SecureStoreConfigurationSource source) : base(source)
1219
{
1320
}
1421

22+
/// <summary>
23+
/// Loads the SecureStore data from a stream.
24+
/// </summary>
25+
/// <param name="stream">The stream to read.</param>
1526
public override void Load(Stream stream)
1627
{
1728
var source = (SecureStoreConfigurationSource)Source;

src/SecureStore.Contrib.Configuration/SecureStoreConfigurationSource.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22
{
33
using Microsoft.Extensions.Configuration;
44

5+
/// <summary>
6+
/// Represents a SecureStore file as an <see cref="IConfigurationSource"/>.
7+
/// </summary>
58
public class SecureStoreConfigurationSource : FileConfigurationSource
69
{
10+
/// <summary>
11+
/// The key to decrypt the SecureStore file.
12+
/// </summary>
713
public string Key { get; set; }
14+
15+
/// <summary>
16+
/// Determines if the key is a password or a key file.
17+
/// </summary>
818
public KeyType KeyType { get; set; }
919

20+
/// <summary>
21+
/// Builds the <see cref="SecureStoreConfigurationProvider"/> for this source.
22+
/// </summary>
23+
/// <param name="builder">The <see cref="IConfigurationBuilder"/>.</param>
24+
/// <returns>A <see cref="SecureStoreConfigurationProvider"/></returns>
1025
public override IConfigurationProvider Build(IConfigurationBuilder builder)
1126
{
12-
FileProvider ??= builder.GetFileProvider();
27+
EnsureDefaults(builder);
1328
return new SecureStoreConfigurationProvider(this);
1429
}
1530
}

0 commit comments

Comments
 (0)