Sportronics.ConfigurationManager
1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Sportronics.ConfigurationManager --version 1.0.3
NuGet\Install-Package Sportronics.ConfigurationManager -Version 1.0.3
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="Sportronics.ConfigurationManager" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sportronics.ConfigurationManager" Version="1.0.3" />
<PackageReference Include="Sportronics.ConfigurationManager" />
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 Sportronics.ConfigurationManager --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sportronics.ConfigurationManager, 1.0.3"
#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 Sportronics.ConfigurationManager@1.0.3
#: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=Sportronics.ConfigurationManager&version=1.0.3
#tool nuget:?package=Sportronics.ConfigurationManager&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sportronics.ConfigurationManager
A flexible configuration management library for .NET applications that handles settings from JSON files and command line arguments.
Features
- Load configuration from JSON files
- Parse and apply command line arguments
- Combine multiple configuration sources with priority order
- Save configuration changes back to JSON files
- Support for both long and short command line argument formats
Installation
dotnet add package Sportronics.ConfigurationManager
Usage
1. Create a settings class
using Sportronics.ConfigurationManager;
public class MyAppSettings : AppSettingsBase
{
public override string SectionName => "MyApp";
public string InputFolder { get; set; } = "default/input";
public string OutputFolder { get; set; } = "default/output";
public bool VerboseLogging { get; set; } = false;
public override string ToString()
{
return $"InputFolder: {InputFolder}, OutputFolder: {OutputFolder}, VerboseLogging: {VerboseLogging}";
}
}
2. Define command line options
var optionsMap = new Dictionary<string, (string LongName, string ShortName)>
{
{ nameof(MyAppSettings.InputFolder), ("input", "i") },
{ nameof(MyAppSettings.OutputFolder), ("output", "o") },
{ nameof(MyAppSettings.VerboseLogging), ("verbose", "v") }
};
3. Process configuration
// Initialize the configuration processor
var configProcessor = new ConfigurationProcessor<MyAppSettings>(
"appsettings.json",
optionsMap);
// Process configuration from all sources
var settings = configProcessor.ProcessConfiguration(args);
// Use the settings
Console.WriteLine($"Using settings: {settings}");
License
This project is licensed under the MIT License - see the LICENSE file for details.
Release Notes
v1.0.2 (August 2025)
- Renamed project from ConfigurationManager to Sportronics.ConfigurationManager
- Improved namespace organization
- Added support for both long and short form command line arguments
- Fixed bug in configuration saving
v1.0.1
- Initial public release
- Basic configuration management functionality
- Support for JSON files and command line arguments
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.7)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.7)
- Microsoft.Extensions.Configuration.CommandLine (>= 9.0.7)
- Microsoft.Extensions.Configuration.Json (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.0.3 - Added project icon