| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using System.Collections.Generic;
- using Utils;
- namespace SiteCore
- {
- /// <summary>
- /// 网站的配置信息
- /// </summary>
- public class config
- {
- private Dictionary<string, string> _dics;
- /// <summary>
- /// 网站的配置信息
- /// </summary>
- public Dictionary<string, string> dics
- {
- get { return _dics; }
- }
- //------------------------------------------------------------
- private config() { loadAll(); }
- private static volatile config _instance;
- private static readonly Object _syncRoot = new object();
- public static config Instance
- {
- get
- {
- if (_instance == null)
- {
- lock (_syncRoot)
- {
- if (_instance == null) _instance = new config();
- }
- }
- return _instance;
- }
- }
- public void Reload()
- {
- loadAll();
- }
- private void loadAll()
- {
- initSiteSettings();
- }
- // ------------------------- site settings -------------------------
- private void initSiteSettings()
- {
- _dics = cfgHelper.Read(siteconfigAbsPath);
- //if (dic.Count <= 0) return;
- }
- private String getVal(Dictionary<String, String> dic, String key)
- {
- String val;
- dic.TryGetValue(key, out val);
- return val;
- }
- internal static readonly String siteconfigAbsPath = getSiteConfigAbsPath();
- private static String getSiteConfigAbsPath()
- {
- return PathHelper.Map(strUtil.Join(cfgHelper.ConfigRoot, "site.config"));
- }
- }
- }
|