OneConfig 1.0.4-alpha

This is a prerelease version of OneConfig.
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OneConfig" Version="1.0.4-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OneConfig" Version="1.0.4-alpha" />
                    
Directory.Packages.props
<PackageReference Include="OneConfig" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OneConfig --version 1.0.4-alpha
                    
#r "nuget: OneConfig, 1.0.4-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OneConfig@1.0.4-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OneConfig&version=1.0.4-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OneConfig&version=1.0.4-alpha&prerelease
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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