API Overview
This section provides the complete API reference for Apq.Cfg.
Core Interfaces
| Interface |
Description |
| ICfgRoot |
Configuration root interface, main entry point |
| ICfgSection |
Configuration section interface |
Core Classes
| Class |
Description |
| CfgBuilder |
Fluent API builder for creating configuration |
Extension Methods
| Category |
Description |
| Extensions |
Extension methods for various configuration sources |
Quick Reference
Creating Configuration
using Apq.Cfg;
var cfg = new CfgBuilder()
.AddJson("config.json", level: 0, writeable: false)
.Build();
Reading Values
// String value
string? value = cfg.Get("App:Name");
// Typed value
int port = cfg.Get<int>("App:Port");
// Check existence
bool exists = cfg.Exists("App:Name");
// Get section
ICfgSection section = cfg.GetSection("Database");
Writing Values
// Set value
cfg.Set("App:Name", "NewName");
// Remove value
cfg.Remove("App:TempKey");
// Save changes
await cfg.SaveAsync();
Batch Operations
// Read multiple
var values = cfg.GetMany(new[] { "Key1", "Key2", "Key3" });
// Write multiple
cfg.SetMany(new Dictionary<string, string?>
{
["Key1"] = "Value1",
["Key2"] = "Value2"
});
Configuration Changes
cfg.ConfigChanges.Subscribe(e =>
{
foreach (var (key, change) in e.Changes)
{
Console.WriteLine($"[{change.Type}] {key}");
}
});
Next Steps