using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; namespace cuidian.Common { public class AppSeting { private static AppSeting __app = new AppSeting(); private AppSeting() { } public static AppSeting Instance { get { return __app; } } public string GetConnectstr(string key) { if (ConfigurationManager.ConnectionStrings[key] == null) { throw new Exception("配置文件中没有连接字串" + key); } return ConfigurationManager.ConnectionStrings[key].ToString(); } public string GetValue(string key) { List list = new List(); //list = (List)ConfigurationManager.AppSettings.Keys.Cast(); if (ConfigurationManager.AppSettings.AllKeys.ToList().Contains(key)) { return ConfigurationManager.AppSettings[key].ToString(); } else { return string.Empty; } } } }