/// <summary> /// 设置客户端配置表数据! /// </summary> /// <param name="config">需要设置的客户端配置项</param> /// <param name="value">设置的最终值</param> public void SetClientConfig(ClientConfigs config, string value) { string key = config.ToString(); if (!m_ClientConfigInfoMap.ContainsKey(key)) { Debug.Log("配置项中不包含" + key); return; } //1:更新xml缓冲区 if (m_ClientConfigInfoMap[key] == value) { return; } m_ClientConfigInfoMap[key] = value; //2:更新客户端xml文件中的内容 LoadConfigXML(ref m_configFileName, false); // 先加载xml文件 XmlNodeList configs = m_xmlDoc.SelectSingleNode(m_configRootName).ChildNodes; foreach (XmlElement element in configs) { if (element.Name == key) { element.InnerText = value; break; } } string rw_Path = AppManager.Inst.readAndWritePath + "Data/" + m_configFileName; //3: 保存到磁盘文件,以后这里需要定时保存,而不是来一条修改信息就保存一次! m_xmlDoc.Save(rw_Path); }
/// <summary> /// 获取客户端 配置项 /// </summary> /// <param name="config">客户端配置项</param> /// <returns></returns> public string GetClientConfig(ClientConfigs config) { string configKey = config.ToString(); if (!m_ClientConfigInfoMap.ContainsKey(configKey)) { //// 先清理客户端缓存信息! //m_ClientConfigInfoMap.Clear(); //// 加载客户端配置文件 //LoadConfigXML(ref m_configFileName, true); //// 读取客户端配置文件 //ReadClientConfig(); //if (GetClientConfig(config) == string.Empty) return(string.Empty); } if (!isConfigFileOK) { return(string.Empty); } return(m_ClientConfigInfoMap[configKey]); }