您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

54 行
1.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Quanjiang.DigitalScholl.PushNotifications
  8. {
  9. internal static class ConfigManager
  10. {
  11. private static readonly bool Error;
  12. private static readonly Configuration AppConfig;
  13. static ConfigManager()
  14. {
  15. var dllPath =$"{AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory}\\Quanjiang.DigitalScholl.PushNotifications.dll";
  16. try
  17. {
  18. AppConfig = ConfigurationManager.OpenExeConfiguration(dllPath);
  19. }
  20. catch (ConfigurationErrorsException)
  21. {
  22. Error = true;
  23. }
  24. }
  25. public static KeyValueConfigurationCollection AppSettings
  26. {
  27. get
  28. {
  29. if (Error) return null;
  30. return AppConfig.AppSettings.Settings;
  31. }
  32. }
  33. public static ConnectionStringSettingsCollection ConnectionStrings
  34. {
  35. get
  36. {
  37. if (Error) return null;
  38. return AppConfig.ConnectionStrings.ConnectionStrings;
  39. }
  40. }
  41. public static T GetSection<T>(string name) where T : ConfigurationSection
  42. {
  43. if (Error) return null;
  44. return AppConfig.GetSection(name) as T;
  45. }
  46. }
  47. }