public static class ConfigManager { public static string GetSetting(string name) { var result = Environment.GetEnvironmentVariable(name); if (string.IsNullOrWhiteSpace(result)) { result = ConfigurationManager.AppSettings[name]; } return result; } public static int? GetIntSetting(string name) { var s = GetSetting(name); if (int.TryParse(s, out int result)) return result; return null; } public static DateTime? GetDateSetting(string name) { var s = GetSetting(name); if (DateTime.TryParse(s, out DateTime result)) return result; return null; } }