Guest User

Untitled

a guest
Jun 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public static class ConfigurationManagerRequired
  2. {
  3. static ConfigurationManagerRequired()
  4. {
  5. AppSettings = new AppSettingsRequired();
  6. }
  7.  
  8. public static AppSettingsRequired AppSettings { get; }
  9.  
  10. public class AppSettingsRequired
  11. {
  12. public string this[string keyName]
  13. {
  14. get
  15. {
  16. if (ConfigurationManager.AppSettings.AllKeys.Contains(keyName))
  17. {
  18. var value = ConfigurationManager.AppSettings[keyName];
  19. if (string.IsNullOrEmpty(value))
  20. {
  21. throw new Exception($"AppSettings key {keyName} is empty");
  22. }
  23.  
  24. return value;
  25. }
  26. else
  27. {
  28. throw new Exception($"AppSettings key {keyName} is not found");
  29. }
  30. }
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment