Repository navigation
Loading Life Cycle
github-actions[bot] edited this page Mar 11, 2026
·
6 revisions
Understanding the exact order in which values are resolved helps you predict the final
state of any property after Build() or Reload().
┌─────────────────────────────────────────────────────────────────────┐
│ STEP 1 — Reset to compiled defaults │
│ Each section's properties are set to their [IniValue(DefaultValue │
│ = …)] values (or the type default when DefaultValue is absent). │
└──────────────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────────────▼──────────────────────────────────────┐
│ STEP 2 — Apply defaults files (AddDefaultsFile order) │
│ Each defaults file is read with IniFileParser and merged into the │
│ sections. Later files win over earlier ones. │
└──────────────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────────────▼──────────────────────────────────────┐
│ STEP 3 — Locate and apply the user INI file │
│ Search directories (AddSearchPath order) are tried until the file │
│ is found. Values in the user file override all defaults. │
│ If not found, the first writable search directory is stored for │
│ a future Save(). │
└──────────────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────────────▼──────────────────────────────────────┐
│ STEP 4 — Apply constants files (AddConstantsFile order) │
│ Admin-forced values that cannot be overridden by users. │
│ These win over everything above. │
└──────────────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────────────▼──────────────────────────────────────┐
│ STEP 5 — Apply external value sources (AddValueSource order) │
│ Each registered IValueSource is queried for every section/key. │
│ Sources are applied in registration order; the last one wins. │
│ During BuildAsync/ReloadAsync, IValueSourceAsync sources are also │
│ queried — after all sync sources, in registration order. │
└──────────────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────────────▼──────────────────────────────────────┐
│ STEP 6 — Fire IAfterLoad hooks │
│ OnAfterLoad() is called on every section that implements │
│ IAfterLoad / IAfterLoad<TSelf>. Use this for normalization, │
│ decryption, derived-value calculation, etc. │
│ During BuildAsync/ReloadAsync, IAfterLoadAsync.OnAfterLoadAsync() │
│ is preferred; IAfterLoad is used as a fallback. │
└──────────────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────────────▼──────────────────────────────────────┐
│ STEP 7 — (Build only) Acquire file lock / start file monitor │
│ If LockFile() or MonitorFile() was configured, the file lock is │
│ acquired and/or the FileSystemWatcher is started. │
└──────────────────────────────┬──────────────────────────────────────┘
│
✅ Ready
Type conversion happens at steps 3 and 4 whenever SetRawValue is called.
The raw string from the INI file is passed through the registered IValueConverter<T>
for the property's type. Built-in converters cover all common .NET primitive types;
custom converters can be registered with ValueConverterRegistry.Register().
- External value sources (
AddValueSource) — applied last, win over everything - Constants files (
AddConstantsFile) — admin-forced, override user file - User INI file (located via
AddSearchPath) — user-editable - Defaults files (
AddDefaultsFile) — baseline values - Compiled defaults (
[IniValue(DefaultValue = "…")]) — fallback when nothing else is set - Type default (
default(T)) — whenDefaultValueis absent
- Loading-Configuration — configuring search paths, defaults, and constants files
-
External-Value-Sources — implementing
IValueSourceandIValueSourceAsync -
Lifecycle-Hooks —
IAfterLoadhooks (Step 6) including async variants - Async-Support — how the async code paths differ from the synchronous ones