- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Quanjiang.DigitalScholl.PushNotifications
- {
- internal static class ConfigManager
- {
- private static readonly bool Error;
-
- private static readonly Configuration AppConfig;
-
- static ConfigManager()
- {
- var dllPath =$"{AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory}\\Quanjiang.DigitalScholl.PushNotifications.dll";
- try
- {
- AppConfig = ConfigurationManager.OpenExeConfiguration(dllPath);
- }
- catch (ConfigurationErrorsException)
- {
- Error = true;
- }
- }
-
- public static KeyValueConfigurationCollection AppSettings
- {
- get
- {
- if (Error) return null;
- return AppConfig.AppSettings.Settings;
- }
- }
-
- public static ConnectionStringSettingsCollection ConnectionStrings
- {
- get
- {
- if (Error) return null;
- return AppConfig.ConnectionStrings.ConnectionStrings;
- }
- }
-
- public static T GetSection<T>(string name) where T : ConfigurationSection
- {
- if (Error) return null;
- return AppConfig.GetSection(name) as T;
- }
- }
- }
|