NamespaceSystemLibrary.Common.Net
Class to load and read configuration files (xml, json or config) as a Class with transformations if exist and with decrypting encrypted properties
Configurations can be placed in either:
~/*.json, ~/*.xml, ~/Configs/**.[json|xml], or ~/Configurations/**.[json|xml]Or appended to your existing 'appSettings.json' file
Transformations are ran based on the 'ASPNETCORE_ENVIRONMENT' variable passed to your applicationRecommended places to set ASPNETCORE_ENVIRONMENT:
- launchSettings.json when using IIS Express- web.config if you use IIS
- mstest.runsettings if you run transformations in unit tests- commandline with --configuration if running as 'exe'
Remarks
The Current instance on the Config object is a Singleton and only loaded once
Read the example of 'EnvironmentConfig.Name' property, it gives details on where/how to set environment per application type
Encrypted properties such as "ApiToken {get;set;}" can be decrypted auto by creating a "ApiTokenDecrypt {get;set;}"must be string, public, and marked with get;set;
convention by specifying suffix "Decrypt" or "Decrypted" or use attribute [Decrypt] on a property
Environment variables like 'UserName' is only added to 'appSettings' reads not your custom configuration files
WARNING: The generic T cannot be a nested classConfig<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 |
Properties
Property Value
Type | Description |
---|---|
T |
Extension Methods
}