SimplerConfig 1.0.1
See the version list below for details.
dotnet add package SimplerConfig --version 1.0.1
NuGet\Install-Package SimplerConfig -Version 1.0.1
<PackageReference Include="SimplerConfig" Version="1.0.1" />
<PackageVersion Include="SimplerConfig" Version="1.0.1" />
<PackageReference Include="SimplerConfig" />
paket add SimplerConfig --version 1.0.1
#r "nuget: SimplerConfig, 1.0.1"
#:package SimplerConfig@1.0.1
#addin nuget:?package=SimplerConfig&version=1.0.1
#tool nuget:?package=SimplerConfig&version=1.0.1
SimplerConfig
This package provides you with a simple-config option for your C# project.
Usage
using SimplerConfig;
var setting = Config.Instance["KEY"];
var nestedSetting = Config.Instance["TopKey:SubKey"];
Options
- Default Configurations should be placed in
appsettings.json. - It will be overwritten by settings in
custom.conf.json - Those settings can be overwritten by Enviroment Variables.
- Finally you can pass settings as CommandLine arguments.
Format
You access sub-elements of JSON with :.
Example:
{
"plugin":
{
"name":"SimpleConfig"
}
}
Access with
SimplerConfig.Config.Instance["plugin:name"]
You can overwrite it by
- changing it in
custom.conf.json - setting
plugin:name="YourName" - or by passing
--plugin:name="AnotherName"
If you can think of a simple way please open an issue 😃
Using Commandline Arguments
To enable the use of commandline arguments add this at the start of your Main(string[] args):
SimplerConfig.Instance.StartArgs = args;
Including JSON Config
By default appsettings.json and custom.conf.json aren't copied on build.
If you want to include the settings with your build you have to add the following to your .csproj file:
[...]
<ItemGroup>
<None Include="custom.conf.json" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"/>
<None Include="appsettings.json" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"/>
</ItemGroup>
</Project>
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.Configuration.CommandLine (>= 5.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 5.0.0)
- Microsoft.Extensions.Configuration.Json (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Moved to SConfig