AbYzzX.Extensions.Settings 0.0.7.1

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

Abyzz.Extensions.Settings

A flexible and extensible settings management library for .NET applications, providing a provider-based architecture for managing configuration data from multiple sources.

Overview

Abyzz.Extensions.Settings is a lightweight library that offers a unified interface for reading and writing configuration settings. It follows a provider pattern, allowing you to implement custom providers for different configuration sources (INI files, JSON, XML, databases, etc.).

Features

  • Provider-based architecture for flexible configuration sources
  • Section-based settings organization
  • Case-insensitive key lookups
  • Type-safe value retrieval with default values
  • Support for multiple data types (string, int, long, bool, double, decimal, DateTime, enum)
  • Built-in INI file provider (via separate package)
  • Simple and intuitive API

Installation

Install the core package:

dotnet add package AbYzzX.Extensions.Settings

For INI file support, also install:

dotnet add package AbYzzX.Extensions.Settings.Ini

Getting Started

Basic Usage

using AbYzzX.Extensions.Settings;

// Create a settings builder
var builder = new SettingsBuilder();

// Add providers (e.g., INI file provider)
builder.AddProvider(new IniSettingsProvider("config.ini"));

// Build and load settings
var settings = builder.Build();

// Read settings
var value = settings.GetSetting("Database", "ConnectionString");

Using Extension Methods for Type-Safe Access

// Get strongly-typed values with defaults
var port = settings.GetInt32("Server", "Port", 8080);
var isEnabled = settings.GetBool("Features", "EnableLogging", false);
var timeout = settings.GetDouble("Connection", "Timeout", 30.0);

Working with Sections

// Get a specific section
var dbSection = settings.GetSection("Database");
if (dbSection != null)
{
    var host = dbSection.GetString("Host", "localhost");
    var port = dbSection.GetInt32("Port", 5432);
}

// Add a new section
var section = settings.AddSection("NewSection");
section.SetValue("Key", "Value");

// Check if section exists
if (settings.ContainsSection("Database"))
{
    // Section exists
}

// Get all section names
var sectionNames = settings.GetSectionNames();

Modifying and Saving Settings

// Add or modify values
var section = settings.GetSection("Database") ?? settings.AddSection("Database");
section.SetValue("ConnectionString", "Server=localhost;Database=mydb");

// Save changes to all providers
settings.Save();

Architecture

Core Interfaces

  • ISettings: Main interface for settings management
  • ISettingsSection: Represents a section containing key-value pairs
  • ISettingsProvider: Interface for implementing custom configuration providers

Extension Methods

The library provides extension methods for both ISettings and ISettingsSection to retrieve typed values:

  • GetString()
  • GetInt16(), GetInt32(), GetInt64()
  • GetBool()
  • GetDouble(), GetDecimal()
  • GetDateTime()
  • GetEnum<T>()

All methods support optional default values.

Boolean Values

By default, the following values are considered as true (case-insensitive):

  • "true"
  • "1"
  • "yes"

You can customize this by modifying:

SettingsExtensions.BoolTrueValues = new[] { "true", "1", "yes", "on" };

INI File Provider

The INI provider supports standard INI file format:

[Database]
Host = localhost
Port = 5432
ConnectionString = Server=localhost;Database=mydb

[Features]
EnableLogging = true
MaxRetries = 3

Using the INI Provider

var builder = new SettingsBuilder();

// Required file (throws exception if not found)
builder.AddProvider(new IniSettingsProvider("config.ini"));

// Optional file (no error if missing)
builder.AddProvider(new IniSettingsProvider("optional.ini", isRequired: false));

var settings = builder.Build();

Comments in INI files start with # and are ignored during parsing.

Creating Custom Providers

Implement the ISettingsProvider interface:

public class CustomProvider : ISettingsProvider
{
    public void Load(ISettings settings)
    {
        // Load configuration from your source
        var section = settings.AddSection("MySection");
        section.SetValue("Key", "Value");
    }

    public void Save(ISettings settings)
    {
        // Save configuration to your source
        foreach (var sectionName in settings.GetSectionNames())
        {
            var section = settings.GetSection(sectionName);
            // Write section data to your storage
        }
    }
}

Requirements

  • .NET 10.0 or later
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AbYzzX.Extensions.Settings:

Package Downloads
AbYzzX.Extensions.Settings.Ini

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.7.1 214 11/27/2025
0.0.7 207 11/27/2025
0.0.6 202 11/26/2025
0.0.5 215 11/24/2025
0.0.4 191 11/22/2025
0.0.3 212 11/22/2025
0.0.2 266 11/22/2025