Net4x.Configuration.Library 2.5.0.26287

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

Net4x.Configuration.Library

A library for reading and writing application settings. It gives one key/value view over several sources: XML .config files, JSON files, URI query strings, environment variables and Microsoft.Extensions.Configuration. It targets .NET Framework 3.5 and later as well as .NET Standard 2.0.

Installation

dotnet add package Net4x.Configuration.Library

Target frameworks: net35, net40, net45, net461, netstandard2.0.

Reading settings with ArgumentGetter

ArgumentGetter.Instance is a process-wide entry point. By default it reads from the entry assembly's configuration.

using ConfigurationLibrary.Arguments;

var culture   = ArgumentGetter.Instance["Culture"];                      // string, "" when missing
int? retries  = ArgumentGetter.Instance.IntegerFromArguments["Retries"];
bool? verbose = ArgumentGetter.Instance.BooleanFromArguments["Verbose"];

Settings in environment variables are merged into the same dictionary, so ArgumentGetter.Instance["USERNAME"] works without extra setup.

Choosing the source

using ConfigurationLibrary.Configuration;

// Read <assembly>.json instead of <assembly>.config
ArgumentGetter.Instance.BaseConfigType = typeof(IJsonConfig);

// Point at another file (resolved as <Location>.config / <Location>.json)
ArgumentGetter.Instance.Location = "AppSeparated";
Interface Source Example file
IAppConfig XML appSettings (the file="…" attribute is honoured) MyApp.exe.config
IJsonConfig JSON with an appSettings object MyApp.json
IUriConfig Query string of a Uri http://host?One=1&Two=2

JSON layout:

{
  "appSettings": {
    "One": "1",
    "Plugin": "exe|My.Namespace.Processor|My.Assembly"
  }
}

Reading from a stream

ArgumentGetter.Instance.BaseConfig.Stream = myStream;
try
{
    var value = ArgumentGetter.Instance["One"];
}
finally
{
    // The configuration is process-wide, so detach the stream when you are done.
    ArgumentGetter.Instance.BaseConfig.Stream = null;
}

Typed values from Microsoft.Extensions.Configuration

var configuration = new ConfigurationBuilder().AddJsonFile("config.json").Build();

ArgumentGetter.Instance.Configuration = configuration;
var folders = ArgumentGetter.Instance
    .GetFromArgument<Dictionary<string, string>>("Data:TargetFolderLocations");

// or use a getter typed for the target
var typed = ArgumentGetter<Dictionary<string, string>>.Instance;
typed.Configuration = configuration;
var sameFolders = typed.FromArguments["Data:TargetFolderLocations"];

Working with a configuration directly

AppConfig, JsonConfig and UriConfig expose shared instances through Instance, and standalone ones through CreateNewInstance():

using ConfigurationLibrary.Configuration.Xml;

var config = AppConfig.Instance;
config.Location = typeof(Program).Assembly.Location;

int? port = config.GetIntegerValue("Port");
DateTime? since = config.GetDateValue("Since", "yyyy-MM-dd");
config["LastRun"] = DateTime.Now.ToString("O");
config.Save();
using ConfigurationLibrary.Configuration.Uri;

UriConfig.Instance.CurrentUri = new Uri("http://localhost?One=1&Plugins=a|b|c");

Where Save() writes

Save() does not overwrite the file shipped with the application. It writes a per-user copy to %USERPROFILE%\<AssemblyCompany>\<file name>.config (or .json). When the entry assembly has no AssemblyCompany attribute, its name is used instead. On the next load, that copy is merged over the shipped file.

AllSettings environment variable

Several settings can be passed in one environment variable called AllSettings, as key=value pairs joined by ArgumentGetter.Instance.Separator:

AllSettingsHelper.PutAllSettingsInArgumentGetter();

Other utilities

  • StringsHelper.Instance: FirstNonEmptyString, MakeCamelPascalCase
  • HttpUtility: URL decoding that also works on .NET Framework 3.5/4.0
  • "...".TryParseJson<T>(out var result): JSON parsing that returns false instead of throwing
  • AppConfigFactory.Instance: the factory behind every shared configuration instance
  • AppConfigFactoryVariables.Instance.DefaultIsCaseSensitive: key case sensitivity (default true)
  • Net4x.Configuration.Interfaces: the contracts this library implements
  • Net4x.Configuration.Crypt: encrypts and decrypts configuration values

Copyright (c) Piero Viano. All rights reserved. Authors: Piero Viano

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 (45)

Showing the top 5 NuGet packages that depend on Net4x.Configuration.Library:

Package Downloads
Net4x.UtilityLibrary

Package Description

Net4x.IoCLibrary

Package Description

Net4x.DataAccessLibrary.Classes

Package Description

Net4x.DapperLibrary.Pivot

Package Description

Net4x.WindowsFormsLibrary

Windows Library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.5.0.26287 57 10/15/2026
2.5.0.26236 6,697 8/24/2026
2.5.0.5 2,266 7/17/2026
2.5.0.4 1,232 2/2/2026
2.5.0.3 716 1/23/2026
2.5.0.2 929 1/5/2026
2.5.0.1 644 12/30/2025
2.5.0 2,055 11/9/2025
1.6.0 6,066 3/31/2025
1.3.0 8,552 8/26/2023
1.3.0-at20230505032208 7,272 5/7/2023