Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class ConfigurationManagerRequired
- {
- static ConfigurationManagerRequired()
- {
- AppSettings = new AppSettingsRequired();
- }
- public static AppSettingsRequired AppSettings { get; }
- public class AppSettingsRequired
- {
- public string this[string keyName]
- {
- get
- {
- if (ConfigurationManager.AppSettings.AllKeys.Contains(keyName))
- {
- var value = ConfigurationManager.AppSettings[keyName];
- if (string.IsNullOrEmpty(value))
- {
- throw new Exception($"AppSettings key {keyName} is empty");
- }
- return value;
- }
- else
- {
- throw new Exception($"AppSettings key {keyName} is not found");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment