wx.Config/ConfigHelper.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
using System.Web.Caching;
using System.Web;
namespace wx.Config
{
public class ConfigHelper
{
/// <summary>
/// 取配置文件中某个参数名对应的参数值
/// </summary>
/// <param name="ParameterName">参数名</param>
/// <returns>返回参数值</returns>
public static string GetParameterValue(string ParameterName)
{
return GetParameterValue("EpowerConfig", ParameterName);
}
/// <summary>
/// 取某个参数配置文件中某个参数名对应的参数值
/// </summary>
/// <param name="ConfigName">配置文件的文件名</param>
/// <param name="ParameterName">参数名</param>
/// <returns>返回参数值</returns>
public static string GetParameterValue(string ConfigName, string ParameterName)
{
Hashtable CommonConfig = GetConfigCache(ConfigName);
if (CommonConfig.ContainsKey(ParameterName))
{
return CommonConfig[ParameterName].ToString();
}
else
{
throw new Exception("参数(" + ParameterName + ")没有定义,请检查配置文件!");
}
}
/// <summary>
/// 将配置的参数转换成Hashtable并存入缓存,配置文件修改后自动更新缓存
/// </summary>
/// <param name="ConfigName">配置文件的文件名</param>
/// <returns>返回Hashtable类型值</returns>
private static Hashtable GetConfigCache(string ConfigName)
{
string CacheName = "Config_" + ConfigName;
Hashtable CommonConfig = new Hashtable();
Cache cache = HttpRuntime.Cache;
if (cache[CacheName] == null)
{
string ConfigPath = HttpContext.Current.Server.MapPath("/Config/");
string ConfigFile = ConfigPath + ConfigName + ".config";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(ConfigFile);
XmlNode oNode = xmlDoc.DocumentElement;
后面还有 18 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。