Config2 1.0.0
dotnet add package Config2 --version 1.0.0
NuGet\Install-Package Config2 -Version 1.0.0
<PackageReference Include="Config2" Version="1.0.0" />
<PackageVersion Include="Config2" Version="1.0.0" />
<PackageReference Include="Config2" />
paket add Config2 --version 1.0.0
#r "nuget: Config2, 1.0.0"
#addin nuget:?package=Config2&version=1.0.0
#tool nuget:?package=Config2&version=1.0.0
Config2
Config2 is a C# library for managing application configuration using JSON and YAML files, environment variables, and user secrets. It provides an easy-to-use interface to read configuration data, with support for type-safe accessors and automatic change monitoring.
Features
- Supports JSON and YAML configuration files
- Supports environment variables and user secrets
- Type-safe accessors for configuration values
- Automatic monitoring of configuration files for changes
- Flexible, easy-to-use interface
Installation
To use Config2, add the library as a dependency to your project using your preferred package manager or by downloading the source code directly.
Usage
Here's a basic example of how to use Config2 in your C# project:
using Config2;
// Get a value from the configuration
string connectionString = StaticConfig.GetValue<string>("ConnectionStrings:DefaultConnection");
// Get a strongly typed object from the configuration
DatabaseSettings dbSettings = StaticConfig.GetObject<DatabaseSettings>("DatabaseSettings");
// Get a collection of objects from the configuration
IEnumerable<Endpoint> endpoints = StaticConfig.GetObjects<Endpoint>("Endpoints");
Configuration Files
By default, Config2 looks for appsettings.json and appsettings.yaml files in your project's root directory. You can specify additional or different files using the AssignJsonFiles and AssignYamlFiles methods:
StaticConfig.AssignJsonFiles("config.json");
StaticConfig.AssignYamlFiles("config.yaml");
User Secrets
To enable user secrets in your configuration, set the UseUserSecrets property to true:
StaticConfig.UseUserSecrets = true;
Note that you'll also need to provide the UserSecretsId in your project file. Refer to the official Microsoft documentation for more information.
Watching for File Changes
To enable automatic monitoring of configuration files for changes, set the WatchForFileChanges property to true:
StaticConfig.WatchForFileChanges = true;
When this feature is enabled, the configuration will be rebuilt automatically whenever a change is detected in any of the monitored files.
License
Config2 is released under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 7.0.0)
- Microsoft.Extensions.Configuration.UserSecrets (>= 7.0.0)
- NetEscapades.Configuration.Yaml (>= 3.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Westwind.Utilities (>= 4.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.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 191 | 4/19/2023 |