Redeon.SuperSiteEngineCore.Web.Eltheon.Core.ConfigFiles
Overview
This package manages hierarchical configuration for Eltheon. It contains base config file abstractions, serializers, discovery helpers, and the extension methods used by GlobalConfig to load strongly typed configuration objects.
Normal hosts connect ConfigFiles to the configs system space before host composition. Reads prefer Storage and fall back per object to the legacy Configs directory only when the Storage object is absent. Writes use the Storage pipeline exclusively and never recreate a deleted legacy Configs directory. Installer hosts without Storage retain atomic legacy writes.
Capabilities
BaseConfigFile<T>handles JSON persistence (with polymorphic support) and path management usingGlobalConfig.ConfigContentStoreprovides safe relative object-key access forConfigs.json,DatabaseConfig.json,Languages.json, andServices/*.json, including source diagnostics for Storage and Legacy.ConfigsFilekeeps a list of discoveredIConfigimplementations.GlobalConfig.Configs()bootstraps this file and scans all loaded assemblies for classes implementingIConfig.ConfigsFile.SaveConfig(Type, IConfig)atomically merges only the changed configuration. Existing JSON tokens for unchanged or temporarily unavailable configurations remain untouched.- Extension methods like
GlobalConfig.GetConfig<T>()allow any feature to fetch its config payload without knowing the storage layout. ConfigOptionsProviderAttribute,IConfigOptionsProvider, andIConfigOptionsResolverprovide dynamic option metadata for admin configuration fields without hard-coding feature-specific select lists in the UI.ConfigCollectionItemProviderAttribute,ConfigCollectionItemDescriptor,IConfigCollectionItemProvider, andIConfigCollectionItemResolverdescribe concrete item types for polymorphic collections such asList<TBase>orList<TInterface>.AddConfigsStore()registers ConfigFiles-owned canonical event metadata, dynamic option resolution, and polymorphic collection item resolution for safe configuration and template-owned database configuration signals.
Usage
- Resolve paths with
GlobalConfig.Initialize(path, ensureDirectories: false)for normal runtime hosts. Installer hosts may explicitly passtrue. - Create a class implementing
IConfigand place it in any loaded assembly. - Add dynamic field options with
[ConfigOptionsProvider(typeof(MyProvider))]when a property should render from runtime-provided choices. - Add polymorphic collection item choices with
[ConfigCollectionItemProvider(typeof(MyItemProvider))]when a list uses an abstract base type or interface and the admin UI must offer concrete item types. - Call
GlobalConfig.Instance.Configs().Load()(or the provided extensions) to populate the config list, then query it viaGetConfig<T>().
Notes
- The package uses Newtonsoft.Json with
TypeNameHandling.Autoto persist polymorphic trigger/config types. Do not remove type metadata unless you control all config consumers. - JSON deserialization replaces initialized collection instances instead of appending into them. This prevents default list values from being duplicated on repeated load/save cycles.
- Dynamic option providers and collection item providers are resolved from DI first and fall back to activator-based construction where possible.
- Collection item descriptors are filtered against the declared collection element type. Disabled or incompatible descriptors must not create posted items.
- Because the extension scans every loaded assembly, keep config classes lightweight to avoid large static initialization costs at startup.
- Configuration/data events never include raw values, secrets, or connection strings. Payloads carry config names, changed keys, provider/context names, redaction flags, and generic reason codes only.
- A corrupt or unreadable Storage object is never masked by a legacy object. Storage write failures never fall back to Legacy.