Skip to content

API Overview

This section provides the complete API reference for Apq.Cfg.

Core Interfaces

InterfaceDescription
ICfgRootConfiguration root interface, main entry point
ICfgSectionConfiguration section interface

Core Classes

ClassDescription
CfgBuilderFluent API builder for creating configuration

Extension Methods

CategoryDescription
ExtensionsExtension methods for various configuration sources

Quick Reference

Creating Configuration

csharp
using Apq.Cfg;

var cfg = new CfgBuilder()
    .AddJsonFile("config.json", level: 0, writeable: false)
    .Build();

Reading Values

csharp
// String value
string? value = cfg["App:Name"];

// Typed value
int port = cfg.GetValue<int>("App:Port");

// Check existence
bool exists = cfg.Exists("App:Name");

// Get section
ICfgSection section = cfg.GetSection("Database");

Writing Values

csharp
// Set value
cfg.SetValue("App:Name", "NewName");

// Remove value
cfg.Remove("App:TempKey");

// Save changes
await cfg.SaveAsync();

Batch Operations

csharp
// Read multiple
var values = cfg.GetMany(new[] { "Key1", "Key2", "Key3" });

// Write multiple
cfg.SetManyValues(new Dictionary<string, string?>
{
    ["Key1"] = "Value1",
    ["Key2"] = "Value2"
});

Configuration Changes

csharp
cfg.ConfigChanges.Subscribe(e =>
{
    foreach (var (key, change) in e.Changes)
    {
        Console.WriteLine($"[{change.Type}] {key}");
    }
});

Next Steps

Released under the MIT License