1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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<string> list = new List<string>();
- //list = (List<string>)ConfigurationManager.AppSettings.Keys.Cast<string>();
- if (ConfigurationManager.AppSettings.AllKeys.ToList().Contains(key))
- {
- return ConfigurationManager.AppSettings[key].ToString();
-
- }
- else
- {
- return string.Empty;
- }
-
- }
- }
- }
|