public string Get(string key) { if (_sf.Contains(key)) { return(_sf.Get(key)); } return(string.Empty); }
public IDictionary <string, string> GetNameDictionary() { SettingFile sf = new SettingFile(String.Format("{0}templates/{1}/tpl.conf", Cms.PyhicPath, this._tplDirName)); String json; if (!sf.Contains("TPL_NAMES") || String.IsNullOrEmpty((json = sf.Get("TPL_NAMES")))) { return(new Dictionary <string, string>()); } return(JsonConvert.DeserializeObject <Dictionary <String, String> >(json)); }
internal static void LoadRelatedIndent() { string relatedConf = String.Format("{0}{1}related_indent.conf", Cms.PyhicPath, CmsVariables.SITE_CONF_PATH); bool isExists = File.Exists(relatedConf); SettingFile sf = new SettingFile(relatedConf); var isModify = false; var isLoaded = false; IDictionary <int, RelateIndent> relatedIndents = ServiceCall.Instance.ContentService.GetRelatedIndents(); IDictionary <int, RelateIndent> newIndents = new Dictionary <int, RelateIndent>(relatedIndents.Count); String key; String value; foreach (var relatedIndent in relatedIndents) { key = relatedIndent.Key.ToString(); if (isExists && sf.Contains(key)) { value = sf.Get(key); isLoaded = true; } else { value = relatedIndent.Value.ToString(); sf.Set(key, value); isModify = true; } newIndents.Add(relatedIndent.Key, new RelateIndent(value)); } if (isModify) { sf.Flush(); } if (isLoaded) { ServiceCall.Instance.ContentService.SetRelatedIndents(newIndents); } }
public TemplateSetting(String tplName, String confPath) { this._tplDirName = tplName; this.tplName = tplName; sf = new SettingFile(confPath); if (sf.Contains("TPL_NAME")) { this.tplName = sf.Get("TPL_NAME"); } #region 获取设置 if (sf.Contains("CFG_ShowError")) { this._cfgShowError = sf["CFG_ShowError"] == "true"; } if (sf.Contains("CFG_EnabledMobiPage")) { this._cfgEnabledMobiPage = sf["CFG_EnabledMobiPage"] == "true"; } if (sf.Contains("CFG_SitemapSplit")) { this._cfgSitemapSplit = sf["CFG_SitemapSplit"]; } if (sf.Contains("CFG_ArchiveTagsFormat")) { this._cfgArchiveTagsFormat = sf["CFG_ArchiveTagsFormat"]; } if (sf.Contains("CFG_NavigatorLinkFormat")) { this._cfgNavigatorLinkFormat = sf["CFG_NavigatorLinkFormat"]; } if (sf.Contains("CFG_NavigatorChildFormat")) { this._cfgNavigatorChildFormat = sf["CFG_NavigatorChildFormat"]; } if (sf.Contains("CFG_FriendShowNum")) { int.TryParse(sf["CFG_FriendShowNum"], out this._cfgFriendShowNum); } if (sf.Contains("CFG_OutlineLength")) { int.TryParse(sf["CFG_OutlineLength"], out this._cfgOutlineLength); } if (sf.Contains("CFG_FriendLinkFormat")) { this._cfgFriendLinkFormat = sf["CFG_FriendLinkFormat"]; } if (sf.Contains("CFG_TrafficFormat")) { this._cfgTrafficFormat = sf["CFG_TrafficFormat"]; } if (sf.Contains("CFG_CommentEditorHtml")) { this._cfgCommentEditorHtml = sf["CFG_CommentEditorHtml"]; } if (sf.Contains("CFG_allowAmousComment")) { this._cfgAllowAmousComment = sf["CFG_allowAmousComment"] == "true"; } if (sf.Contains("CFG_ArchiveFormat")) { this._cfgArchiveFormat = sf["CFG_ArchiveFormat"]; } if (sf.Contains("CFG_PrevArchiveFormat")) { this._cfgPrevArchiveFormat = sf["CFG_PrevArchiveFormat"]; } if (sf.Contains("CFG_NextArchiveFormat")) { this._cfgNextArchiveFormat = sf["CFG_NextArchiveFormat"]; } if (sf.Contains("CFG_ArchiveLinkFormat")) { this._cfgArchiveLinkFormat = sf["CFG_ArchiveLinkFormat"]; } if (sf.Contains("CFG_CategoryLinkFormat")) { this._cfgCategoryLinkFormat = sf["CFG_CategoryLinkFormat"]; } sf = null; #endregion }
/// <summary> /// 判断设置项的值是否为真 /// </summary> /// <param name="sf"></param> /// <param name="key"></param> /// <returns></returns> private static bool CheckTrueValue(SettingFile sf, string key) { return(sf.Contains(key) && sf.Get(key) == "true"); }