Table of Contents

Namespace SharpConsoleUI.Registry

Classes

AppRegistry

The main registry API. Holds an in-memory JsonNode tree and delegates persistence to an IRegistryStorage backend. Supports multiple flush modes: eager (every Set), manual (explicit Save()), lazy (timer-based), and auto-on-shutdown (via RegistryStateService).

Thread-safety: AppRegistry.OpenSection() and Save()/Load() are thread-safe via ReaderWriterLockSlim. Individual RegistrySection instances are NOT thread-safe — do not share a section instance across threads without external synchronization.

JsonFileStorage

Default IRegistryStorage implementation. Persists the registry as a pretty-printed UTF-8 JSON file. Writes directly to the target path (no atomic rename — acceptable for user preferences and window state where data loss on crash is tolerable). Load() returns null if the file does not exist.

MemoryStorage

In-memory IRegistryStorage implementation for testing. No file I/O. Each Save() stores a deep clone so mutations to the original don't affect stored data.

RegistrySection

A live view of a node in the registry tree. Provides typed get/set for primitive types, AOT-safe generic types, and sub-section navigation. RegistrySection is a lightweight wrapper — it holds no independent state beyond a reference to its JsonObject node and the parent AppRegistry (for flush callbacks).

Thread-safety note: RegistrySection instances are NOT individually thread-safe. Do not share a single RegistrySection instance across threads without external synchronization.

Interfaces

IRegistryStorage

Abstraction for registry persistence. The contract uses JsonNode because the registry's in-memory model IS a JsonNode tree. Custom backends may serialize it to any wire format internally.