3.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-17T16:08:08.424741+00:00 | zai-org/GLM-5-FP8 | 1 | 20e6632b3b560005 |
Config
Purpose
Provides centralized, thread-safe access to an alternate configuration file for the application. This module exists to allow the system to read settings and configuration sections from a dynamically-specified config file path rather than the default application configuration, supporting scenarios where configuration needs to be externalized or swapped at runtime.
Public Interface
DTSConfig (static class)
-
static void DTSConfigInit(string path)— Initializes the configuration system with the specified config file path. Internally callsSetAltConfigPath. -
static void AltConfigPathSet(string path)— Thread-safe setter for the alternate config file path. Acquires lock onMyLockbefore assigning. -
static string AltConfigPathGet()— Thread-safe getter for the alternate config file path. Acquires lock onMyLockbefore returning. -
static void SetAltConfigPath(string path)— Sets the alternate config path and opens the mapped configuration file. Ifpathis null or empty, falls back toDTSConstants.CustomConfigPath. Creates a newConfigurationobject viaConfigurationManager.OpenMappedExeConfiguration. -
static Configuration GetAltConfig()— Thread-safe getter returning the currentConfigurationobject for the alternate config file. -
static string GetAppSetting(string key)— Retrieves an app setting value by key from the alternate configuration. Returnsstring.Emptyif the key is not found (logs a message viaAPILogger.Login that case). -
static object GetSection(string sectionName)— Retrieves a configuration section by name from the alternate configuration. Returnsnullif the section is not found (logs a message viaAPILogger.Login that case).
Invariants
- All access to static fields (
AltConfigPath,AltConfig) is protected by a lock onMyLockfor thread safety. SetAltConfigPathmust be called beforeGetAppSettingorGetSectioncan return meaningful results; otherwise,AltConfigmay be null.GetAppSettingalways returns a non-null string (empty string if key not found).GetSectionmay return null if the section does not exist.
Dependencies
Depends on:
DTS.Common.Utilities.Logging(usesAPILogger.Log)System.Configuration(usesConfiguration,ConfigurationManager,ExeConfigurationFileMap,KeyValueConfigurationElement,ConfigurationUserLevel)DTSConstants.CustomConfigPath(referenced constant, defined elsewhere in the codebase)
Dependents: Unknown from source alone.
Gotchas
- The static constructor is empty, meaning
AltConfigis not initialized untilSetAltConfigPathis explicitly called. CallingGetAppSettingorGetSectionbefore initialization will result in aNullReferenceException. DTSConfigInitandSetAltConfigPathappear to be redundant;DTSConfigInitsimply delegates toSetAltConfigPathwith no additional logic.AltConfigPathGetandAltConfigPathSetare separate methods rather than a property, which is unconventional for C#.- The
GetAppSettingmethod uses LINQ to cast and search settings, which is less efficient than using theAppSettings.Settings[key]indexer, but handles the case where the key might not exist gracefully.