Config2 1.0.0

dotnet add package Config2 --version 1.0.0
                    
NuGet\Install-Package Config2 -Version 1.0.0
                    
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="Config2" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Config2" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Config2" />
                    
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 Config2 --version 1.0.0
                    
#r "nuget: Config2, 1.0.0"
                    
#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.
#addin nuget:?package=Config2&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Config2&version=1.0.0
                    
Install as a Cake Tool

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 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. 
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.0 191 4/19/2023