OneConfig 1.0.4-alpha
See the version list below for details.
dotnet add package OneConfig --version 1.0.4-alpha
NuGet\Install-Package OneConfig -Version 1.0.4-alpha
<PackageReference Include="OneConfig" Version="1.0.4-alpha" />
<PackageVersion Include="OneConfig" Version="1.0.4-alpha" />
<PackageReference Include="OneConfig" />
paket add OneConfig --version 1.0.4-alpha
#r "nuget: OneConfig, 1.0.4-alpha"
#:package OneConfig@1.0.4-alpha
#addin nuget:?package=OneConfig&version=1.0.4-alpha&prerelease
#tool nuget:?package=OneConfig&version=1.0.4-alpha&prerelease
OneConfig
OneConfig is a simple library for managing application configuration.
Usage
With OneConfig, the only configuration you need in your app.config or web.config is a reference to a location in which your configuration can be found.
<add key="OneConfig_Source" value="(see below)"/>
The value may be any one of the following:
- The string "this file" which uses the app.config or web.config itself.
- The string "windows environment" which reads values from the Windows Environment
- The string "command line" which reads values from the command line in the form /key:value or /key:"value"
- A sql connection string, which assumes your configuration is in a table called ConfigurationSettings with "Name" and "Value" columns
- A path to an xml file, followed by an xpath expression indicating the node that contains configuration settings. Configuration entries themselves are assume to be add tags in with a key and value attribute.
To access configuration values at runtime, use the static AppConfig class.
- AppConfig.GetValue("Key") - returns the configuration value with the given key
- AppConfig.GetValueSource("Key") - returns what source provides the given configuration value
- AppConfig.SetValue("Key", "Value") - adds or changes a configuration at runtime
- AppConfig.ResetToDefault("Key") - undoes SetValue, reverting the configuration to what it was at app startup
- AppConfig.AddReader(reader) - allows you to inject a class at runtime that can provide configuration values
Using Multiple Configuration Sources
You can add additional Source elements, suffixed with increasing numbers.
<add key="OneConfig_Source" value="this file"/>
<add key="OneConfig_Source2" value="Override\configuration.xml//settings"/>
You may use as many sources as you need. For any given configuration key, the highest numbered source that contains that configuration is the one that will be used.
Configuration Variables
The value for any configuration key may refer to other configuration values by using the #{ } syntax
Example:
<add key="FullName" value="#{First Name} {Last Name"} />
<add key="First Name" value="Jane" />
<add key="Last Name" value="Doe"} />
The other variables need not come from the same configuration source. Variables that cannot be resolved are left as is. Any variables with a circular dependency will result in a CyclicVariableDependencyException
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Dapper (>= 1.50.5)
- StructureMap (>= 4.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.11-beta | 22,575 | 4/3/2019 |
1.0.10-beta | 493 | 4/2/2019 |
1.0.9-alpha | 22,648 | 2/2/2019 |
1.0.8-alpha | 836 | 1/26/2019 |
1.0.7-alpha | 840 | 1/26/2019 |
1.0.6-alpha | 829 | 1/24/2019 |
1.0.5-alpha | 843 | 1/23/2019 |
1.0.4-alpha | 834 | 1/23/2019 |
1.0.3-alpha | 882 | 1/17/2019 |
1.0.2-alpha | 881 | 1/13/2019 |
1.0.1-alpha | 873 | 1/13/2019 |
1.0.0-alpha | 903 | 1/12/2019 |
Alpha Release