NamespaceSystemLibrary.Common.Framework
Loads and reads configuration files (.xml, .json, or .config), applies transformations, and decrypts encrypted properties.
Configs can be placed in:
~/*.json, ~/*.xml, ~/Configs/**, ~/Configurations/**, or appended to appsettings.json.
Transformations use the ASPNETCORE_ENVIRONMENT variable.
Set ASPNETCORE_ENVIRONMENT in:
- launchSettings.json (IIS Express/Kestrel)
- web.config (IIS/IIS Express)
- mstest.runsettings (unit tests)
- command-line --configuration (executables)
Remarks
Config is a singleton, loaded once.
See documentation for EnvironmentConfig.Name for environment setup examples.
An encrypted property such as ApiToken {get;set;} can be automatically decrypted by adding a matching property ApiTokenDecrypt {get;set;} or mark it with [ConfigDecryptAttribute].
Environment variables like UserName apply only when reading appSettings, not custom config files.
WARNING: Generic type T cannot be a nested class.
Config<T>
public abstract class Config<T> where T : class
Type Parameters
Name | Description |
---|---|
T | T is the class inheriting Config<>, also referenced as 'self'. Note that T cannot be a nested class |
Fields
Remarks
Config is a singleton, loaded once.
See documentation for EnvironmentConfig.Name for environment setup examples.
An encrypted property such as ApiToken {get;set;} can be automatically decrypted by adding a matching property ApiTokenDecrypt {get;set;} or mark it with [ConfigDecryptAttribute].
Environment variables like UserName apply only when reading appSettings, not custom config files.
WARNING: Generic type T cannot be a nested class.
Field Value
Type | Description |
---|---|
T |
Extension Methods
}