Skip to content

Commit fe2a6b4

Browse files
Merge pull request #49 from aspnet/2.0-Beta
Rev to 'beta' and do a minor doc scrub.
2 parents 1dad682 + 5a06cd8 commit fe2a6b4

12 files changed

Lines changed: 53 additions & 48 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Version 2 is here with some new features:
2424
## Key/Value Config Builders
2525

2626
If you read the blog post linked above, you probably recognize that Configuration Builders can be quite flexible. Applications can use the Configuration Builder
27-
concept to construct incredibly complex configuration on the fly. But for the most common usage scenarios, a simple key/value replacement mechanism is all that
27+
concept to construct incredibly complex configuration on the fly. But for the most common usage scenarios, a basic key/value replacement mechanism is all that
2828
is needed. Most of the config builders in this project are such key/value builders.
2929

3030
#### mode
@@ -36,13 +36,13 @@ set to run in three different modes:
3636
external source.
3737
* `Greedy` - This mode is closely related to `Strict` mode, but instead of being limited to keys that already exist in the original configuration, the config builders
3838
will dump all key/value pairs from the external source into the resulting config section.
39-
* `Expand` - This last mode operates on the raw xml before it gets parsed into a config section object. It can be thought of as a simple expansion of tokens in a
39+
* `Expand` - This last mode operates on the raw xml before it gets parsed into a config section object. It can be thought of as a basic expansion of tokens in a
4040
string. Any part of the raw xml string that matches the pattern __`${token}`__ is a candidate for token expansion. If no corresponding value is found in the
4141
external source, then the token is left alone.
4242

4343
#### prefix
4444
Another feature of these key/value Configuration Builders is prefix handling. Because full-framework .Net configuration is complex and nested, and external key/value
45-
sources are by nature quite simple and flat, leveraging key prefixes can be useful. For example, if you want to inject both App Settings and Connection Strings into
45+
sources are by nature quite basic and flat, leveraging key prefixes can be useful. For example, if you want to inject both App Settings and Connection Strings into
4646
your configuration via environment variables, you could accomplish this in two ways. Use the `EnvironmentConfigBuilder` in the default `Strict` mode and make sure you
4747
have the appropriate key names already coded into your config file. __OR__ you could use two `EnvironmentConfigBuilder`s in `Greedy` mode with distinct prefixes
4848
so they can slurp up any setting or connection string you provide without needing to update the raw config file in advance. Like this:
@@ -63,10 +63,10 @@ This way the same flat key/value source can be used to populate configuration fo
6363
#### stripPrefix
6464
A related setting that is common among all of these key/value builders is `stripPrefix`. The code above does a good job of separating app settings from connection
6565
strings... but now all the keys in AppSettings start with "AppSetting_". Maybe this is fine for code you wrote. Chances are that prefix is better off stripped from the
66-
key name before being inserted into AppSettings. `stripPrefix` is a simple boolean value, and accomplishes just that. It's default value is `false`.
66+
key name before being inserted into AppSettings. `stripPrefix` is a boolean value, and accomplishes just that. It's default value is `false`.
6767

6868
#### optional
69-
This setting is a simple boolean that specified whether to avoid throwing exceptions when the backing configuration source cannot be found or connected.
69+
This setting is a boolean that specified whether to avoid throwing exceptions when the backing configuration source cannot be found or connected.
7070
The default default value is `true`, though some config builders (such as the Azure-based builders) will use a different default.
7171

7272
#### tokenPattern
@@ -75,7 +75,7 @@ above, it was mentioned that the raw xml is searched for tokens that look like _
7575
The set of characters that matches `\w` is more strict than xml and many sources of config values allow, and some applications may need to allow more exotic characters
7676
in their token names. Additionally there might be scenarios where the `${}` pattern is not acceptable.
7777

78-
`tokenPattern` allows developers to change the regex that is used for token matching. It is a simple string argument, and no validation is done to make sure it is
78+
`tokenPattern` allows developers to change the regex that is used for token matching. It is a string argument, and no validation is done to make sure it is
7979
a well-formed non-dangerous regex - so use it wisely. The only real restriction is that is must contain a capture group. The entire regex must match the entire token,
8080
and the first capture must be the token name to look up in the config source.
8181

@@ -122,7 +122,7 @@ preceded with an '@' symbol.
122122
[mode|@prefix|@stripPrefix|tokenPattern|@optional=true]
123123
type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment" />
124124
```
125-
This is the simplest of the config builders. It draws its values from Environment, and it does not have any additional configuration options.
125+
This is the most basic of the config builders. It draws its values from Environment, and it does not have any additional configuration options.
126126
* __NOTE:__ In a Windows container environment, variables set at run time are only injected into the EntryPoint process environment.
127127
Applications that run as a service or a non-EntryPoint process will not pick up these variables unless they are otherwise injected through
128128
some mechanism in the container. For [IIS](https://github.com/Microsoft/iis-docker/pull/41)/[ASP.Net](https://github.com/Microsoft/aspnet-docker)-based
@@ -255,7 +255,7 @@ entries: `item1` and `item2`.
255255
[keyDelimiter=":"]
256256
type="Microsoft.Configuration.ConfigurationBuilders.KeyPerFileConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.KeyPerFile" />
257257
```
258-
This is a simple config builder that uses a directory's files as a source of values. A file's name is the key, and the contents are the value. This
258+
This config builder uses a directory's files as a source of values. A file's name is the key, and the contents are the value. This
259259
config builder can be useful when running in an orchestrated container environment, as systems like Docker Swarm and Kubernetes provide 'secrets' to
260260
their orchestrated windows containers in this key-per-file manner.
261261
* `directoryPath` - This is a required attribute. It specifies a path to the source directory to look in for values. Docker for Windows secrets
@@ -275,7 +275,7 @@ their orchestrated windows containers in this key-per-file manner.
275275
Because .Net Core projects can rely heavily on json files for configuration, it makes some sense to allow those same files to be used in full-framework
276276
configuration as well. You can imagine that the heirarchical nature of json might enable some fantastic capabilities for building complex configuration sections.
277277
But this config builders is meant to be a simple mapping from a flat key/value source into specific key/value areas of full-framework configuration. Thus its name
278-
begins with 'Simple.' Think of the backing json file as a simple dictionary, rather than a comlex heirarchical object.
278+
begins with 'Simple.' Think of the backing json file as a basic dictionary, rather than a comlex heirarchical object.
279279

280280
(A multi-level heirarchical file can be used. This provider will simply 'flatten' the depth by appending the property name at each level using ':' as a delimiter.)
281281

@@ -345,7 +345,7 @@ When adding additional handlers, the name of the section must be 'Microsoft.Conf
345345

346346
If you don't see a config builder here that suits your needs, you can write your own. Referencing the `Basic` nuget package for this project will get you the base upon which
347347
all of these builders inherit. Most of the heavy-ish lifting and consistent behavior across key/value config builders comes from this base. Take a look at the code for more
348-
detail, but in many cases implementing a custom key/value config builder in this same vein is as simple as inheriting the base, and implementing two simple methods.
348+
detail, but in many cases implementing a custom key/value config builder in this same vein is as easy as inheriting the base, and implementing two basic methods.
349349
```CSharp
350350
using Microsoft.Configuration.ConfigurationBuilders;
351351

samples/SampleWebApp/Web.config

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<builders>
2525
<add name="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral" />
2626
<add name="Secrets" userSecretsFile="~/App_Data/secrets.xml" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets, Version=2.0.0.0, Culture=neutral" />
27-
<add name="SimpleJson" jsonFile="${JSONConfigFile}" optional="true" type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json, Version=2.0.0.0, Culture=neutral" />
27+
<add name="Json" jsonFile="${JSONConfigFile}" optional="true" type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json, Version=2.0.0.0, Culture=neutral" />
2828
<add name="KeyPerFile" directoryPath="~/../KeyPerFileSampleRoot" mode="Strict" keyDelimiter="--" type="Microsoft.Configuration.ConfigurationBuilders.KeyPerFileConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.KeyPerFile, Version=2.0.0.0, Culture=neutral" />
2929

3030
<add name="KV1" vaultName="${ConfigBuilderTestKeyVaultName}" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral" />
@@ -36,20 +36,20 @@
3636
</builders>
3737
</configBuilders>
3838

39-
<appSettings configBuilders="Environment,Secrets,SimpleJson,KeyPerFile">
39+
<appSettings configBuilders="Environment,Secrets,Json,KeyPerFile">
4040
<add key="WINDIR" value="Will be replaced by 'Environment' in Strict and Greedy modes." />
4141
<add key="SYSTEMDRIVE" value="Will initally be replaced by 'Environment' in Strict and Greedy modes... but then superceded by 'Secrets' in the same modes." />
4242
<add key="Value_Replaced_By_Environment_In_Expand_Mode" value="${WINDIR}" />
4343
<add key="ARCHITECTURE" value="Will be replaced by 'Environment' in Strict/Greedy modes IFF prefix='PROCESSOR_' AND stripPrefix='true'" />
4444
<add key="PROCESSOR_ARCHITECTURE" value="Will be left untouched by 'Environment' in Strict/Greedy modes if IFF prefix='PROCESSOR_' AND stripPrefix='true'" />
45-
<add key="jsonSetting1" value="Will be replaced by 'SimpleJson' in Strict and Greedy modes." />
46-
<add key="Value_Replaced_By_SimpleJson_In_Expand_Mode" value="${jsonSetting1}" />
47-
<add key="appSettings:jsonSubSetting2" value="Will be replaced by 'SimpleJson' in Strict and Greedy modes." />
48-
<add key="jsonSubSetting2" value="Will be replaced by 'SimpleJson' in 'Sectional' jsonMode." />
49-
<add key="jsonSub:subSetting3" value="Will be replaced by 'SimpleJson' in 'Sectional' jsonMode." />
50-
<add key="jsonConnectionString1" value="WILL be replaced by 'SimpleJson' in 'Flat' jsonMode." />
51-
<add key="jsonConnectionString2" value="WILL NOT be replaced by 'SimpleJson' in 'Sectional' jsonMode." />
52-
<add key="jsonCustomSetting1" value="Will be replaced by 'SimpleJson' with prefix='customSettings:' and stripPrefix='true'." />
45+
<add key="jsonSetting1" value="Will be replaced by 'Json' in Strict and Greedy modes." />
46+
<add key="Value_Replaced_By_Json_In_Expand_Mode" value="${jsonSetting1}" />
47+
<add key="appSettings:jsonSubSetting2" value="Will be replaced by 'Json' in Strict and Greedy modes." />
48+
<add key="jsonSubSetting2" value="Will be replaced by 'Json' in 'Sectional' jsonMode." />
49+
<add key="jsonSub:subSetting3" value="Will be replaced by 'Json' in 'Sectional' jsonMode." />
50+
<add key="jsonConnectionString1" value="WILL be replaced by 'Json' in 'Flat' jsonMode." />
51+
<add key="jsonConnectionString2" value="WILL NOT be replaced by 'Json' in 'Sectional' jsonMode." />
52+
<add key="jsonCustomSetting1" value="Will be replaced by 'Json' with prefix='customSettings:' and stripPrefix='true'." />
5353
<add key="SecretFromFile1" value="This will be replaced by KeyPerFile." />
5454
<add key="SECRETFROMFILE2" value="As will this one." />
5555
<add key="SubFeature--FeatureSecretA" value="This will be replaced by KeyPerFile if keyDelimiter is set to '--'." />
@@ -62,11 +62,11 @@
6262
<!-- key="Secret3" value="Will be added by KV3:Latest3. IFF already added, will be "updated" by KV1 to Latest3. KV2 and KV4 don't have versions matching this secret." -->
6363
</appSettings>
6464

65-
<connectionStrings configBuilders="SimpleJson">
66-
<add name="jsonConnectionString1" connectionString="Will be replaced by 'SimpleJson' in 'Flat' AND 'Sectional' jsonModes, but with different values." />
67-
<add name="connectionStrings:jsonConnectionString1" connectionString="Will only be replaced by 'SimpleJson' in 'Flat' jsonMode." />
68-
<add name="jsonConnectionString2" connectionString="Will only be replaced by 'SimpleJson' in 'Sectional' jsonMode." />
69-
<add name="customSettings:jsonConnectionString2" connectionString="Will be replaced by 'SimpleJson' in 'Flat' jsonMode." />
65+
<connectionStrings configBuilders="Json">
66+
<add name="jsonConnectionString1" connectionString="Will be replaced by 'Json' in 'Flat' AND 'Sectional' jsonModes, but with different values." />
67+
<add name="connectionStrings:jsonConnectionString1" connectionString="Will only be replaced by 'Json' in 'Flat' jsonMode." />
68+
<add name="jsonConnectionString2" connectionString="Will only be replaced by 'Json' in 'Sectional' jsonMode." />
69+
<add name="customSettings:jsonConnectionString2" connectionString="Will be replaced by 'Json' in 'Flat' jsonMode." />
7070
</connectionStrings>
7171

7272
<system.web>

src/Base/KeyValueConfigBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
namespace Microsoft.Configuration.ConfigurationBuilders
1212
{
1313
/// <summary>
14-
/// Base class for a set of ConfigurationBuilders that follow a simple key/value pair substitution model. This base
15-
/// class handles substitution modes and most prefix concerns, so implementing classes only need to be a simple
14+
/// Base class for a set of ConfigurationBuilders that follow a basic key/value pair substitution model. This base
15+
/// class handles substitution modes and most prefix concerns, so implementing classes only need to be a basic
1616
/// source of key/value pairs through the <see cref="GetValue(string)"/> and <see cref="GetAllValues(string)"/> methods.
1717
/// </summary>
1818
public abstract class KeyValueConfigBuilder : ConfigurationBuilder

src/KeyPerFile/KeyPerFileConfigBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected override void LazyInitialize(string name, NameValueCollection config)
6161

6262
// The Core KeyPerFile config provider does not do multi-level.
6363
// If KeyDelimiter is null, do single-level. Otherwise, multi-level.
64-
// Empty string will do multi-level with simple non-delimited concatenation in greedy mode.
64+
// Empty string will do multi-level with basic non-delimited concatenation in greedy mode.
6565
// Empty string will be effectively single-level in other modes.
6666
KeyDelimiter = config[keyDelimiterTag];
6767
}

src/packages/ConfigurationBuilders.Azure.nupkg/Microsoft.Configuration.ConfigurationBuilders.Azure.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<owners>Microsoft</owners>
88
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
99
<title>Microsoft Configuration Builders - Azure Builders</title>
10-
<description>A set of Configuration Builders for the .Net Desktop Framework that draw from Azure resources.</description>
11-
<summary>A set of Configuration Builders for the .Net Desktop Framework that draw from Azure resources.</summary>
10+
<description>A set of Configuration Builders for the .Net Framework that draw from Azure resources.</description>
11+
<summary>A set of Configuration Builders for the .Net Framework that draw from Azure resources.</summary>
1212
<language>en-US</language>
1313
<projectUrl>https://github.com/aspnet/MicrosoftConfigurationBuilders</projectUrl>
1414
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>

src/packages/ConfigurationBuilders.AzureAppConfiguration.nupkg/Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<owners>Microsoft</owners>
88
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
99
<title>Microsoft Configuration Builders - AzureAppConfiguration Builder</title>
10-
<description>A set of Configuration Builders for the .Net Desktop Framework that draw from Azure AppConfiguration stores.</description>
11-
<summary>A set of Configuration Builders for the .Net Desktop Framework that draw from Azure AppConfiguration stores.</summary>
10+
<description>A set of Configuration Builders for the .Net Framework that draw from Azure AppConfiguration stores.</description>
11+
<summary>A set of Configuration Builders for the .Net Framework that draw from Azure AppConfiguration stores.</summary>
1212
<language>en-US</language>
1313
<projectUrl>https://github.com/aspnet/MicrosoftConfigurationBuilders</projectUrl>
1414
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>

src/packages/ConfigurationBuilders.Base.nupkg/Microsoft.Configuration.ConfigurationBuilders.Base.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<owners>Microsoft</owners>
88
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
99
<title>Microsoft Configuration Builders - Base</title>
10-
<description>In .Net 4.7.1, the configuration system allows applications to use ConfigurationBuilders to build up and modify configuration at runtime when it is loaded. This package provides a base framework to ease development of simple key/value configuration builders.</description>
11-
<summary>A base framework for simple key/value Configuration Builders for the .Net Desktop Framework.</summary>
10+
<description>In .Net 4.7.1, the configuration system allows applications to use ConfigurationBuilders to build up and modify configuration at runtime when it is loaded. This package provides a base framework to ease development of basic key/value configuration builders.</description>
11+
<summary>A base framework for basic key/value Configuration Builders for the .Net Framework.</summary>
1212
<language>en-US</language>
1313
<projectUrl>https://github.com/aspnet/MicrosoftConfigurationBuilders</projectUrl>
1414
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>

src/packages/ConfigurationBuilders.Environment.nupkg/Microsoft.Configuration.ConfigurationBuilders.Environment.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<owners>Microsoft</owners>
88
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
99
<title>Microsoft Configuration Builders - Environment</title>
10-
<description>A simple key/value Configuration Builder for the .Net Desktop Framework that draws from environment variables.</description>
11-
<summary>A simple key/value Configuration Builder for the .Net Desktop Framework that draws from environment variables.</summary>
10+
<description>A basic key/value Configuration Builder for the .Net Framework that draws from environment variables.</description>
11+
<summary>A basic key/value Configuration Builder for the .Net Framework that draws from environment variables.</summary>
1212
<language>en-US</language>
1313
<projectUrl>https://github.com/aspnet/MicrosoftConfigurationBuilders</projectUrl>
1414
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>

src/packages/ConfigurationBuilders.Json.nupkg/Microsoft.Configuration.ConfigurationBuilders.Json.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<owners>Microsoft</owners>
88
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
99
<title>Microsoft Configuration Builders - Json Builders</title>
10-
<description>A simple key/value Configuration Builder for the .Net Desktop Framework that draws from a json file.</description>
11-
<summary>A simple key/value Configuration Builder for the .Net Desktop Framework that draws from a json file.</summary>
10+
<description>A basic key/value Configuration Builder for the .Net Framework that draws from a json file.</description>
11+
<summary>A basic key/value Configuration Builder for the .Net Framework that draws from a json file.</summary>
1212
<language>en-US</language>
1313
<projectUrl>https://github.com/aspnet/MicrosoftConfigurationBuilders</projectUrl>
1414
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>

0 commit comments

Comments
 (0)