You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Configuration;
-
- namespace Quanjiang.DigitalScholl.SendSms
- {
- 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.SendSms.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;
- }
- }
- }
|