public bool ParseFromXmlString(string content, string channel) { bool bRet = false; try { SecurityParser parser = new SecurityParser(); parser.LoadXml(content); SecurityElement root = parser.ToXml(); for (int i = 0; i < (root.Children?.Count ?? 0); ++i) { if (root.Children != null) { SecurityElement eleLocale = (SecurityElement)root.Children[i]; if (eleLocale.Tag != channel) { continue; } for (int j = 0; j < (eleLocale.Children?.Count ?? 0); ++j) { if (eleLocale.Children != null) { SecurityElement ele = (SecurityElement)eleLocale.Children[j]; switch (ele.Tag) { case "UpdateServer1": UpdateServerUrls.Add(ele.Attribute("url")); break; case "UpdateServer2": UpdateServerUrls.Add(ele.Attribute("url")); break; case "UpdateServer3": UpdateServerUrls.Add(ele.Attribute("url")); break; case "ClientServer": ClientServerUrl = ele.Attribute("url"); break; } } } } } parser.Clear(); bRet = true; } catch (Exception e) { UnityEngine.Debug.LogError(string.Format("Exception {0}", e.Message)); } return(bRet); }
public bool ParseFromXmlString(string content) { try { SecurityParser parser = new SecurityParser(); parser.LoadXml(content); SecurityElement root = parser.ToXml(); for (int i = 0; i < (root.Children?.Count ?? 0); ++i) { if (root.Children != null) { SecurityElement ele = (SecurityElement)root.Children[i]; switch (ele.Tag) { case "SystemRequireMemory": this.SystemRequireMemory = ele.Attribute("text"); break; case "SystemRequireSpace": this.SystemRequireSpace = ele.Attribute("text"); break; case "UpdateStateSuccess": this.UpdateStateSuccess = ele.Attribute("text"); break; case "UpdateStateDiskSpaceFullErr": this.UpdateStateDiskSpaceFullErr = ele.Attribute("text"); break; case "UpdateStateGetLocalVersionErr": this.UpdateStateGetLocalVersionErr = ele.Attribute("text"); break; case "UpdateStateGetServerVersionErr": this.UpdateStateGetServerVersionErr = ele.Attribute("text"); break; case "UpdateStateNetworkErr": this.UpdateStateNetworkErr = ele.Attribute("text"); break; case "UpdateStateNetConnectionErr": this.UpdateStateNetConnectionErr = ele.Attribute("text"); break; case "UpdateStateNetUnstable": this.UpdateStateNetUnstable = ele.Attribute("text"); break; case "UpdateStateStartUpdateInfo": this.UpdateStateStartUpdateInfo = ele.Attribute("text"); break; case "UpdateStateUnknownErr": this.UpdateStateUnknownErr = ele.Attribute("text"); break; case "UpdateStateDownloadingErrAutoRetry": this.UpdateStateDownloadingErrAutoRetry = ele.Attribute("text"); break; case "UpdateStatusStart": this.UpdateStatusStart = ele.Attribute("text"); break; case "UpdateStatusTryGetLocalVersion": this.UpdateStatusTryGetLocalVersion = ele.Attribute("text"); break; case "UpdateStatusTryCheckFreeSpace": this.UpdateStatusTryCheckFreeSpace = ele.Attribute("text"); break; case "UpdateStatusTryGetNewVersion": this.UpdateStatusTryGetNewVersion = ele.Attribute("text"); break; case "UpdateStatusTryDnsResolving": this.UpdateStatusTryDnsResolving = ele.Attribute("text"); break; case "UpdateStatusSuccessGetVersions": this.UpdateStatusSuccessGetVersions = ele.Attribute("text"); break; case "UpdateStatusBeginUpdate": this.UpdateStatusBeginUpdate = ele.Attribute("text"); break; case "UpdateStatusDownloading": this.UpdateStatusDownloading = ele.Attribute("text"); break; case "UpdateStatusDownloadingServerList": this.UpdateStatusDownloadingServerList = ele.Attribute("text"); break; case "UpdateStatusCompressPack": this.UpdateStatusCompressPack = ele.Attribute("text"); break; case "UpdateStringCurrentVersion": this.UpdateStringCurrentVersion = ele.Attribute("text"); break; case "UpdateStringServerVersion": this.UpdateStringServerVersion = ele.Attribute("text"); break; case "UpdateStringYes": this.UpdateStringYes = ele.Attribute("text"); break; case "UpdateStringNo": this.UpdateStringNo = ele.Attribute("text"); break; case "UpdateStringOk": this.UpdateStringOk = ele.Attribute("text"); break; case "UpdateStringCancel": this.UpdateStringCancel = ele.Attribute("text"); break; case "UpdateStringHasErrorNotWifi": this.UpdateStringHasErrorNotWifi = ele.Attribute("text"); break; case "UpdateStringHasErrorRetry": this.UpdateStringHasErrorRetry = ele.Attribute("text"); break; case "UpdateStringHasError": this.UpdateStringHasError = ele.Attribute("text"); break; case "UpdateStringHasFatalErrorNeedReinstall": this.UpdateStringHasFatalErrorNeedReinstall = ele.Attribute("text"); break; case "UpdateStringPrepareForFirstTimeUse": this.UpdateStringPrepareForFirstTimeUse = ele.Attribute("text"); break; case "UpdateStringEnsureEnoughSpace": this.UpdateStringEnsureEnoughSpace = ele.Attribute("text"); break; case "UpdateStringTextUpdate": this.UpdateStringTextUpdate = ele.Attribute("text"); break; case "UpdateStringFileSize": this.UpdateStringFileSize = ele.Attribute("text"); break; case "UpdateStringDownloadSpeed": this.UpdateStringDownloadSpeed = ele.Attribute("text"); break; case "UpdateStatusWifiTips": this.UpdateStatusWifiTips = ele.Attribute("text"); break; default: break; } } } parser.Clear(); return(true); } catch (Exception e) { UnityEngine.Debug.LogError(string.Format("Exception {0}", e.Message)); } return(false); }
private void ParseCgConfigFile(string cgName, bool isVideo) { string configsDir = System.IO.Path.Combine(EntryPoint.Instance.ResPath, LuaScriptMgr.Instance.GetConfigsDir()); var configPath = string.Empty; if (isVideo) { configPath = System.IO.Path.Combine(configsDir, "VideoConfig.xml"); } else { configPath = System.IO.Path.Combine(configsDir, "CgConfig.xml"); } var bytes = Util.ReadFile(configPath); if (bytes == null) { return; } try { string text = Encoding.UTF8.GetString(bytes); SecurityParser sp = Main.XMLParser; sp.LoadXml(text); SecurityElement root = sp.ToXml(); foreach (SecurityElement se1 in root.Children) { if (se1.Tag != cgName) { continue; } foreach (SecurityElement se2 in se1.Children) { if (se2.Tag == "Dialogue") { foreach (SecurityElement se3 in se2.Children) { var dialogue = new Dialogue(); dialogue.Name = se3.Attribute("name"); dialogue.Content = se3.Attribute("content"); var showStr = se3.Attribute("show"); dialogue.ShowTime = string.IsNullOrEmpty(showStr)? 0 : float.Parse(showStr); var closeStr = se3.Attribute("close"); dialogue.HideTime = string.IsNullOrEmpty(closeStr) ? 0 : float.Parse(closeStr); if (!_CgXmlConfig.Dialogues.ContainsKey(se3.Tag)) { _CgXmlConfig.Dialogues.Add(se3.Tag, dialogue); } } } else if (se2.Tag == "Name") { foreach (SecurityElement se3 in se2.Children) { if (!_CgXmlConfig.Names.ContainsKey(se3.Tag)) { _CgXmlConfig.Names.Add(se3.Tag, se3.Attribute("name")); } } } else if (se2.Tag == "CGMask") { _CgXmlConfig.IsMaskShown = bool.Parse(se2.Attribute("mask")); } } break; } sp.Clear(); } catch (Exception e) { Debug.LogError(HobaText.Format(e.Message)); } }