public static String getBySkin(String key) { string value = ""; string local = getLangString(); string _skinname = string.Empty; Dictionary <String, String> _core = null; Dictionary <String, String> _lang = null; try { _core = (Dictionary <String, String>)System.Caching.SysCache.Get("TemplateLanguageDic"); } catch { } try { _lang = (Dictionary <String, String>)System.Caching.SysCache.Get("TemplateLanguageDic" + local); } catch { } try { if (_core == null) { try { _core = cfgHelper.Read(PathHelper.Map(cfgHelper.FrameworkRoot + System.TemplateEngine.TeConfig.Instance.TemplateFolder + "/" + System.TemplateEngine.TeConfig.Instance.CurrentSkin + "/lang.config"), '='); System.Caching.SysCache.Put("TemplateLanguageDic", _core); } catch { _core = new Dictionary <String, String>(); System.Caching.SysCache.Put("TemplateLanguageDic", _core); } } if (_lang == null) { try { _lang = cfgHelper.Read(PathHelper.Map(cfgHelper.FrameworkRoot + System.TemplateEngine.TeConfig.Instance.TemplateFolder + "/" + System.TemplateEngine.TeConfig.Instance.CurrentSkin + "/lang." + local + ".config"), '='); System.Caching.SysCache.Put("TemplateLanguageDic" + local, _lang); } catch { _core = new Dictionary <String, String>(); System.Caching.SysCache.Put("TemplateLanguageDic" + local, _core); } } if (string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(value)) { try { value = _lang[key]; } catch { } if (string.IsNullOrEmpty(value)) { try { value = _core[key]; } catch { } if (string.IsNullOrEmpty(value)) { try { value = getKey(key); } catch { } } } } } } catch {} return(value); }
/// <summary> /// 读取配置文件,返回一个对象。 /// </summary> /// <typeparam name="T">对象的类型</typeparam> /// <param name="fileName">纯文件名称,不包括路径(默认是在 /xcenter/conf/ 目录下)</param> /// <param name="separator">键和值之间的分隔符</param> /// <returns>返回 T 类型的对象</returns> private static T ReadByFile <T>(String fileName, char separator) { String path = PathHelper.Map(strUtil.Join(cfgHelper.ConfigRoot, fileName)); return(Read <T>(path, separator)); }