public void Init() { this.m_oDicAllStringData.Clear(); XmlDocument doc = XmlResAdapter.GetXmlDocument(UnityTools.LoadFileText(SystemConfig.StringPath)); OnLoadStringFinishedEventHandler(doc); }
public void Init() { string strRelativePath = "config/gameconfig.xml"; XmlDocument xmlDocument = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strRelativePath, false)); this.OnLoadFinishEventHandler(xmlDocument); }
void Start() { if (!string.IsNullOrEmpty(path)) { string path1 = dic + "/" + path; XmlDocument xmlDocument = XmlResAdapter.GetXmlDocument(path1); print(xmlDocument.InnerXml); File.WriteAllText(targetPath + path, xmlDocument.InnerXml, Encoding.UTF8); } }
public void Init() { try { string strRelativePath = "config/publish.xml"; XmlDocument xmlDocument = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strRelativePath, false)); this.OnLoadFinishEventHandler(xmlDocument); } catch (Exception ex) { this.m_log.Fatal(ex.ToString()); } }
public void LoadXml(string strConfigFile) { if (string.IsNullOrEmpty(strConfigFile)) { EffectLogger.Error("LoadXml:string.IsNullOrEmpty(strConfigFile) == true"); } else { try { XmlDocument xmlDocument = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strConfigFile, false)); XmlNode xmlNode = xmlDocument.SelectSingleNode("EffectPool"); if (null == xmlNode) { EffectLogger.Error("null == root"); } else { XmlNodeList xmlNodeList = xmlNode.SelectNodes("Effect"); if (null == xmlNodeList) { EffectLogger.Error("null == nodeList"); } else { foreach (XmlNode effectNode in xmlNodeList) { EffectData effectData = new EffectData(); if (effectData.Load(effectNode)) { if (!this.m_EffectDatas.ContainsKey(effectData.Id)) { this.m_EffectDatas.Add(effectData.Id, effectData); } else { EffectLogger.Debug("true == m_EffectDatas.ContainsKey(data.Id):" + effectData.Id); } } } } } } catch (Exception ex) { EffectLogger.Error(ex.ToString()); } } }
/// <summary> /// 初始化地图信息,根据地图配置文件 /// </summary> /// <param name="mapID">地图id</param> /// <param name="strConfigFile">配置文件xml</param> /// <returns></returns> public bool Init(uint mapID, string strConfigFile) { this.m_MapID = mapID; if (!string.IsNullOrEmpty(strConfigFile)) { string strRelativePath = string.Format("config/{0}", strConfigFile); XmlDocument xmlDocument = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strRelativePath, false)); this.OnLoadFinishEventHandler(xmlDocument); } else { Debug.LogError("null == strMapFile:" + mapID); } return(true); }
/// <summary> /// 将xml转换成list<T>列表类 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="xmlText"></param> /// <returns></returns> private static List <T> LoadXMLText <T>(string xmlText) { List <T> list = new List <T>(); try { if (string.IsNullOrEmpty(xmlText)) { return(list); } Type type = typeof(T); XmlDocument doc = XmlResAdapter.GetXmlDocument(xmlText); Dictionary <int, Dictionary <string, string> > map = XmlResAdapter.LoadXMLToMap(doc, xmlText); var props = type.GetProperties(~System.Reflection.BindingFlags.Static); foreach (var item in map) { var obj = type.GetConstructor(Type.EmptyTypes).Invoke(null); foreach (var prop in props) { if (prop.Name == "id") { prop.SetValue(obj, item.Key, null); } else { try { if (item.Value.ContainsKey(prop.Name)) { var value = UnityTools.GetValue(item.Value[prop.Name], prop.PropertyType); prop.SetValue(obj, value, null); } } catch (Exception e) { Debug.LogException(e); } } } list.Add((T)obj); } } catch (Exception e) { Debug.LogException(e); } return(list); }
public void Init() { try { string strRelativePath = "config/string.xml"; XmlDocument xmlDocument = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strRelativePath, false)); this.OnLoadStringFinishEventHandler(xmlDocument); string strRelativePath2 = "config/errorcode.xml"; XmlDocument xmlDocument2 = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strRelativePath2, false)); this.OnLoadErrorCodeStringFinishEventHandler(xmlDocument2); string strRelativePath3 = "config/tips.xml"; XmlDocument xmlDocument3 = XmlResAdapter.GetXmlDocument(ResourceManager.GetFullPath(strRelativePath3, false)); this.OnLoadTipsStringFinishEventHandler(xmlDocument3); } catch (Exception ex) { this.m_log.Fatal(ex.ToString()); } }
/// <summary> /// 取得下载包的信息 /// </summary> /// <param name="AsynResult"></param> /// <param name="OnError"></param> private void DownloadPackageInfoList(Action <List <PackageInfo> > AsynResult, Action OnError) { //从服务器版本信息中取得下载Url,然后初始化下载包的信息 DownloadMgr.Instance.AsynDownLoadHtml(ServerVersion.PackageMd5List, (content) => { XmlDocument doc = XmlResAdapter.GetXmlDocument(content); if (null == doc) { if (OnError != null) { OnError(); } } else { List <PackageInfo> packagesList = new List <PackageInfo>(); foreach (XmlNode node in doc.SelectSingleNode("root").ChildNodes) { PackageInfo package = new PackageInfo(); string packagetName = node.Attributes["name"].Value; package.Name = packagetName; //从第7个开始,也就是说前7个是/名称,这里我取名/LOLPa/,放资源包的文件夹,后4位是索引/001 string version = packagetName.Substring(7, packagetName.Length - 11); //中间是低版本和高版本===>比如0.0.0.0-0.0.0.3 string firstVersion = version.Substring(0, version.IndexOf("-")); package.LowVersion = new VersionCodeInfo(firstVersion); string endVersion = version.Substring(firstVersion.Length + 1); package.HighVersion = new VersionCodeInfo(endVersion); //然后内容是md5码 package.MD5 = node.InnerText; packagesList.Add(package); ServerVersion.PackageMd5Dic.Add(package.Name, package.MD5); } AsynResult(packagesList); } }, OnError); }
private VersionManagerInfo GetVersionInXml(string verXml) { XmlDocument doc = XmlResAdapter.GetXmlDocument(verXml); if (doc != null && doc.ChildNodes != null && doc.ChildNodes.Count != 0) { VersionManagerInfo version = new VersionManagerInfo(); var props = typeof(VersionManagerInfo).GetProperties(); foreach (XmlNode item in doc.SelectSingleNode("root").ChildNodes) { var prop = props.FirstOrDefault(t => t.Name == item.Name); if (prop != null) { prop.SetValue(version, item.InnerText, null); } } return(version); } else { return(new VersionManagerInfo()); } }