This repository was archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathKeyPerFileConfigurationSource.cs
More file actions
48 lines (42 loc) · 1.75 KB
/
KeyPerFileConfigurationSource.cs
File metadata and controls
48 lines (42 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.IO;
using Microsoft.Extensions.FileProviders;
namespace Microsoft.Extensions.Configuration.KeyPerFile
{
/// <summary>
/// An <see cref="IConfigurationSource"/> used to configure <see cref="KeyPerFileConfigurationProvider"/>.
/// </summary>
public class KeyPerFileConfigurationSource : IConfigurationSource
{
/// <summary>
/// Constructor;
/// </summary>
public KeyPerFileConfigurationSource()
=> IgnoreCondition = s => IgnorePrefix != null && s.StartsWith(IgnorePrefix);
/// <summary>
/// The FileProvider whos root "/" directory files will be used as configuration data.
/// </summary>
public IFileProvider FileProvider { get; set; }
/// <summary>
/// Files that start with this prefix will be excluded.
/// Defaults to "ignore.".
/// </summary>
public string IgnorePrefix { get; set; } = "ignore.";
/// <summary>
/// Used to determine if a file should be ignored using its name.
/// Defaults to using the IgnorePrefix.
/// </summary>
public Func<string, bool> IgnoreCondition { get; set; }
/// <summary>
/// If false, will throw if the directory doesn't exist.
/// </summary>
public bool Optional { get; set; }
/// <summary>
/// Builds the <see cref="KeyPerFileConfigurationProvider"/> for this source.
/// </summary>
/// <param name="builder">The <see cref="IConfigurationBuilder"/>.</param>
/// <returns>A <see cref="KeyPerFileConfigurationProvider"/></returns>
public IConfigurationProvider Build(IConfigurationBuilder builder)
=> new KeyPerFileConfigurationProvider(this);
}
}