5.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T11:41:16.907673+00:00 | zai-org/GLM-5-FP8 | 1 | 2693b2d1a0d0acee |
Documentation: DTSConfig.cs
1. Purpose
DTSConfig is a static utility class that provides centralized access to application configuration settings from an alternate configuration file. It exists to allow the application to read settings from a custom .config file path rather than the default application configuration, supporting scenarios where configuration needs to be externalized or shared across components. The class acts as a configuration facade, wrapping System.Configuration.ConfigurationManager functionality with thread-safe access and logging for missing keys or sections.
2. Public Interface
AltConfigPathGet()
Signature: public static string AltConfigPathGet()
Returns the currently set alternate configuration file path. Thread-safe via locking on MyLock.
AltConfigPathSet(string path)
Signature: public static void AltConfigPathSet(string path)
Sets the alternate configuration file path. Updates AltConfigPath only; does not reload the configuration. Thread-safe via locking on MyLock.
DTSConfigInit(string path)
Signature: public static void DTSConfigInit(string path)
Initializes the configuration system by calling SetAltConfigPath(path). This is the primary entry point for setting up the alternate configuration at application startup.
GetAltConfig()
Signature: public static Configuration GetAltConfig()
Returns the System.Configuration.Configuration object representing the loaded alternate configuration file. Thread-safe via locking on MyLock.
SetAltConfigPath(string path)
Signature: public static void SetAltConfigPath(string path)
Sets the alternate configuration path and immediately loads the configuration file. If path is null or empty, falls back to DTSConstants.CustomConfigPath. Creates an ExeConfigurationFileMap and opens the configuration via ConfigurationManager.OpenMappedExeConfiguration. Thread-safe via locking on MyLock.
GetAppSetting(string key)
Signature: public static string GetAppSetting(string key)
Retrieves an application setting value by key from the alternate configuration's AppSettings section. Returns string.Empty if the key is not found (logs a warning via APILogger.Log). Does not throw exceptions for missing keys.
GetSection(string sectionName)
Signature: public static object GetSection(string sectionName)
Retrieves a configuration section by name from the alternate configuration. Returns null if the section is not found (logs a warning via APILogger.Log). Used by plugin code to retrieve plugin library sections.
3. Invariants
- Thread Safety: All access to static fields (
AltConfigPath,AltConfig) is protected by a lock onMyLock. - Configuration Initialization:
AltConfigis populated whenSetAltConfigPath()is called; callingGetAppSetting()orGetSection()before initialization will result in aNullReferenceException(not guarded against in source). - Fallback Path: When
SetAltConfigPath(string path)receives a null or empty path, it usesDTSConstants.CustomConfigPathas the configuration file location. - Missing Key Handling:
GetAppSetting()returnsstring.Emptyfor missing keys rather thannullor throwing an exception. - Missing Section Handling:
GetSection()returnsnullfor missing sections and logs the absence.
4. Dependencies
This module depends on:
DTS.Common.Utilities.Logging— UsesAPILogger.Log()for warning messagesSystem.Configuration— UsesConfiguration,ConfigurationManager,ExeConfigurationFileMap,KeyValueConfigurationElement,ConfigurationUserLevelSystem.Linq— UsesCast<>()andFirstOrDefault()DTSConstants.CustomConfigPath— Referenced constant (defined elsewhere, location not shown in source)
What depends on this module:
- Unclear from source alone — No consumers are shown in this file. The
GetSection()method documentation mentions "plugin code" as a consumer.
5. Gotchas
-
Redundant API Surface: Both
DTSConfigInit()andSetAltConfigPath()perform the same operation.DTSConfigInit()simply delegates toSetAltConfigPath()with no additional logic. -
Inconsistent Naming Convention: The class exposes both
AltConfigPathGet()/AltConfigPathSet()(Java-style) andSetAltConfigPath()(C#-style) methods for similar operations, creating potential confusion. -
Uninitialized State Not Guarded: Calling
GetAppSetting()orGetSection()beforeSetAltConfigPath()orDTSConfigInit()will throw aNullReferenceExceptionsinceAltConfigstarts asnull. -
Empty Static Constructor: The static constructor is explicitly defined but empty, which is unnecessary.
-
Silent Failure on Missing Keys: Missing configuration keys return
string.Emptyrather than throwing, which may mask configuration errors. Consumers must check for empty string rather than null. -
ReSharper Suppressions: The file suppresses
InconsistentNamingwarnings, suggesting naming conventions in this file deviate from project standards.