private void FromXml(string xml) { SecurityParser sp = new SecurityParser(); sp.LoadXml(xml); SecurityElement root = sp.ToXml(); if (root.Tag == "KeyPair") { //SecurityElement prop = root.SearchForChildByTag ("Properties"); SecurityElement keyv = root.SearchForChildByTag("KeyValue"); if (keyv.Children.Count > 0) { _keyvalue = keyv.Children [0].ToString(); } // Note: we do not read other stuff because // it can't be changed after key creation } }
// 加载一个表完成 public void onLoadEventHandle(IDispatchObject dispObj) { ResItem res = dispObj as ResItem; //Ctx.m_instance.m_logSys.debugLog_1(LangItemID.eItem0, res.GetPath()); // 这行执行的时候 m_isLoaded 设置加载标志,但是 m_nodeList 还没有初始化 Ctx.m_instance.m_logSys.log("local xml loaded"); string text = res.getText(m_ID2FileName[m_langID].m_filePath); if (text != null) { SecurityParser SP = new SecurityParser(); SP.LoadXml(text); SecurityElement SE = SP.ToXml(); m_nodeList = SE.Children; } // 卸载资源 Ctx.m_instance.m_resLoadMgr.unload(res.GetPath(), onLoadEventHandle); }
static SecurityElement FromString(string xml) { if (xml == null) { throw new ArgumentNullException("xml"); } if (xml.Length == 0) { throw new XmlSyntaxException(Locale.GetText("Empty string.")); } try { SecurityParser sp = new SecurityParser(); sp.LoadXml(xml); return(sp.ToXml()); } catch (Exception e) { string msg = Locale.GetText("Invalid XML."); throw new XmlSyntaxException(msg, e); } }
private PermissionSet CreateFromXml(string xml) { #if !NET_2_1 SecurityParser sp = new SecurityParser(); try { sp.LoadXml(xml); } catch (Mono.Xml.SmallXmlParserException xe) { throw new XmlSyntaxException(xe.Line, xe.ToString()); } SecurityElement se = sp.ToXml(); string className = se.Attribute("class"); if (className == null) { return(null); } PermissionState state = PermissionState.None; if (CodeAccessPermission.IsUnrestricted(se)) { state = PermissionState.Unrestricted; } if (className.EndsWith("NamedPermissionSet")) { NamedPermissionSet nps = new NamedPermissionSet(se.Attribute("Name"), state); nps.FromXml(se); return((PermissionSet)nps); } else if (className.EndsWith("PermissionSet")) { PermissionSet ps = new PermissionSet(state); ps.FromXml(se); return(ps); } #endif return(null); }
protected override bool OnPrepare(UnityEngine.Object mainAsset) { if (base.OnPrepare(mainAsset) == false) { return(false); } TextAsset temp = mainAsset as TextAsset; if (temp == null) { return(false); } SecurityParser sp = new SecurityParser(); sp.LoadXml(temp.text); _xml = sp.ToXml(); if (_xml == null) { LogSystem.Log(ELogType.Error, $"SecurityParser.LoadXml failed. {ResName}"); return(false); } try { // 解析数据 ParseData(); } catch (Exception ex) { LogSystem.Log(ELogType.Error, $"Failed to parse xml {ResName}. Exception : {ex.ToString()}"); return(false); } // 注意:为了节省内存这里立即释放了资源 UnLoad(); return(true); }
public override void FromXmlString(string xmlString) { if (xmlString == null) { throw new ArgumentNullException("xmlString"); } DSAParameters dsaParams = new DSAParameters(); try { SecurityParser sp = new SecurityParser(); sp.LoadXml(xmlString); SecurityElement se = sp.ToXml(); if (se.Tag != "DSAKeyValue") { throw new Exception(); } dsaParams.P = GetNamedParam(se, "P"); dsaParams.Q = GetNamedParam(se, "Q"); dsaParams.G = GetNamedParam(se, "G"); dsaParams.J = GetNamedParam(se, "J"); dsaParams.Y = GetNamedParam(se, "Y"); dsaParams.X = GetNamedParam(se, "X"); dsaParams.Seed = GetNamedParam(se, "Seed"); byte[] counter = GetNamedParam(se, "PgenCounter"); if (counter != null) { byte[] counter4b = new byte [4]; // always 4 bytes Buffer.BlockCopy(counter, 0, counter4b, 0, counter.Length); dsaParams.Counter = BitConverterLE.ToInt32(counter4b, 0); } ImportParameters(dsaParams); } catch { ZeroizePrivateKey(dsaParams); throw; } finally { ZeroizePrivateKey(dsaParams); } }
/// <summary> /// Reconstructs a <see cref="DiffieHellman"/> object from an XML string. /// </summary> /// <param name="xmlString">The XML string to use to reconstruct the DiffieHellman object.</param> /// <exception cref="CryptographicException">One of the values in the XML string is invalid.</exception> public override void FromXmlString(string xmlString) { if (xmlString == null) { throw new ArgumentNullException(); } DHParameters dhParams = new DHParameters(); try { SecurityParser sp = new SecurityParser(); sp.LoadXml(xmlString); SecurityElement se = sp.ToXml(); if (se.Tag != "DHKeyValue") { throw new CryptographicException(); } dhParams.P = GetNamedParam(se, "P"); dhParams.G = GetNamedParam(se, "G"); dhParams.X = GetNamedParam(se, "X"); ImportParameters(dhParams); } finally { if (dhParams.P != null) { Array.Clear(dhParams.P, 0, dhParams.P.Length); } if (dhParams.G != null) { Array.Clear(dhParams.G, 0, dhParams.G.Length); } if (dhParams.X != null) { Array.Clear(dhParams.X, 0, dhParams.X.Length); } } }
public void ParseData(string path, string strData) { SecurityParser parser = new SecurityParser(); parser.LoadXml(strData); SecurityElement element = parser.ToXml(); ResCfgInfo info; if (m_dicCfgInfo.TryGetValue(path, out info)) { Type dataReaderTType = typeof(DataReader <>); //Type dataReaderTType = typeof(ResCfgSys).GetNestedType("DataReader`1"); Type dataReaderDataType = dataReaderTType.MakeGenericType(new Type[] { info.type }); MethodInfo addMethod = dataReaderDataType.GetMethod("Add", BindingFlags.Static | BindingFlags.Public); foreach (SecurityElement node in element.Children) { var value = Activator.CreateInstance(info.type, node); var key = info.keyProperty.GetValue(value, null); addMethod.Invoke(null, new object[] { key, value }); } } }
static public void Build(bool forceRebuild) { AssetBundlePipeline.Clear(); SecurityParser parser = new SecurityParser(); var str = File.ReadAllText(PATH); parser.LoadXml(str); SecurityElement e = parser.ToXml(); List <AssetBunldeBuilgGroup> groupList = new List <AssetBunldeBuilgGroup>(); foreach (SecurityElement node in e.Children) { groupList.Add(new AssetBunldeBuilgGroup(node)); } foreach (AssetBunldeBuilgGroup group in groupList) { group.Execute(); } var outputPath = "AssetBundles/android"; if (forceRebuild) { if (Directory.Exists(outputPath)) { Directory.Delete(outputPath, true); } Directory.CreateDirectory(outputPath); } else if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } AssetBundlePipeline.Build(outputPath, BuildTarget.Android, forceRebuild); }
private void Parser(WWW www) { m_LoadOk = true; if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); xmlDoc.LoadXml(www.text); ArrayList worldXmlList = xmlDoc.ToXml().Children; foreach (SecurityElement xeTreasureBoxs in worldXmlList) { if (xeTreasureBoxs.Tag == "TreasureBoxes") { ArrayList TreasureBoxXmlList = xeTreasureBoxs.Children; foreach (SecurityElement xeTreasureBox in TreasureBoxXmlList) { if (xeTreasureBox.Tag == "TreasureBox") { TreasureBox tBox = new TreasureBox(); tBox.treasureBoxId = Convert.ToInt32(xeTreasureBox.Attribute("Id")); tBox.type = Convert.ToInt32(xeTreasureBox.Attribute("Type")); ArrayList TreasureXmlList = xeTreasureBox.Children; foreach (SecurityElement xeTreasure in TreasureXmlList) { if (xeTreasure.Tag == "Treasure") { Treasure TreasureInfo = new Treasure(); TreasureInfo.itemId = Convert.ToInt32(xeTreasure.Attribute("ItemId")); TreasureInfo.count = Convert.ToInt32(xeTreasure.Attribute("Value")); tBox.items.Add(TreasureInfo); } } treasureBoxInfo.Add(tBox.treasureBoxId, tBox); } } } } } }
static private void LoadFileList(Action callback = null) { #if UNITY_EDITOR SaveFileList(); #endif //加载文件列表 MyFileUtil.ReadConfigDataAsync(FileListConfigFileName, (xmlContent) => { //string xmlContent = MyFileUtil.ReadConfigData(FileListConfigFileName); Loom.RunAsync(() => { SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(xmlContent); SecurityElement xml = securityParser.ToXml(); for (int i = 0; i < xml.Children.Count; i += 2) { var key = xml.Children[i] as System.Security.SecurityElement; var value = xml.Children[i + 1] as System.Security.SecurityElement; if (m_DictFileInfo.ContainsKey(key.Text)) { string str = string.Format("ResourcesManager.LoadFileList:资源名{0}重复", key.Text); //Debug.LogError(str); continue; } m_DictFileInfo.Add(key.Text, value.Text); } Loom.QueueOnMainThread(() => { if (callback != null) { callback(); } }); }); }); }
public override void FromXmlString(string xmlString) { if (xmlString == null) { throw new ArgumentNullException(); } DHParameters parameters = default(DHParameters); try { SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(xmlString); SecurityElement securityElement = securityParser.ToXml(); if (securityElement.Tag != "DHKeyValue") { throw new CryptographicException(); } parameters.P = GetNamedParam(securityElement, "P"); parameters.G = GetNamedParam(securityElement, "G"); parameters.X = GetNamedParam(securityElement, "X"); ImportParameters(parameters); } finally { if (parameters.P != null) { Array.Clear(parameters.P, 0, parameters.P.Length); } if (parameters.G != null) { Array.Clear(parameters.G, 0, parameters.G.Length); } if (parameters.X != null) { Array.Clear(parameters.X, 0, parameters.X.Length); } } }
public static TdirConfigData GetFileTdirAndTverData() { if (TdirConfig.tdirConfigData == null && File.Exists(Application.persistentDataPath + TdirConfig.tdirConfigDataPath)) { try { byte[] array = CFileManager.ReadFile(Application.persistentDataPath + TdirConfig.tdirConfigDataPath); if (array != null && array.Length > 0) { TdirConfig.tdirConfigData = new TdirConfigData(); string @string = Encoding.get_UTF8().GetString(array); SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(@string); SecurityElement securityElement = securityParser.ToXml(); using (IEnumerator enumerator = securityElement.get_Children().GetEnumerator()) { while (enumerator.MoveNext()) { SecurityElement securityElement2 = (SecurityElement)enumerator.get_Current(); if (securityElement2.get_Tag() == "serverType") { TdirConfig.tdirConfigData.serverType = int.Parse(securityElement2.get_Text()); } else if (securityElement2.get_Tag() == "versionType") { TdirConfig.tdirConfigData.versionType = int.Parse(securityElement2.get_Text()); } } } } } catch (Exception) { TdirConfig.tdirConfigData = null; } } return(TdirConfig.tdirConfigData); }
private void Parser(WWW www) { m_LoadOk = true; GuLog.Debug("RoleConfigPath WWW::" + www.error); if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); GuLog.Debug("RoleConfigPath" + www.text); xmlDoc.LoadXml(www.text); ArrayList worldXmlList = xmlDoc.ToXml().Children; foreach (SecurityElement xeWorld in worldXmlList) { if (xeWorld.Tag == "Roles") { ArrayList roleXmlList = xeWorld.Children; foreach (SecurityElement xeRole in roleXmlList) { if (xeRole.Tag == "Role") { RoleInfo roleInfo = new RoleInfo(); roleInfo.roleId = Convert.ToInt32(xeRole.Attribute("Id")); roleInfo.Name = xeRole.Attribute("Name"); roleInfo.ChineseName = xeRole.Attribute("ChineseName"); roleInfo.Storage = xeRole.Attribute("Storage"); roleInfo.AB = xeRole.Attribute("AB"); roleInfo.ModelPath = xeRole.Attribute("ModelPath"); roleInfo.GuestPath = xeRole.Attribute("GuestPath"); roleInfos.Add(roleInfo.Name, roleInfo); } } } } } }
public Dictionary <string, int> LoadTemplateObjectList(Action action) { string actionName = action.actionName; CBinaryObject cBinaryObject = ActionManager.Instance.resLoader.LoadAge(actionName) as CBinaryObject; if (cBinaryObject == null) { return(new Dictionary <string, int>()); } SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(Encoding.get_UTF8().GetString(cBinaryObject.m_data)); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(actionName); SecurityElement securityElement = securityParser.SelectSingleNode("Project"); SecurityElement securityElement2 = (securityElement != null) ? securityElement.SearchForChildByTag("TemplateObjectList") : null; if (securityElement2 != null) { action.templateObjectIds.Clear(); if (securityElement2.get_Children() != null) { for (int i = 0; i < securityElement2.get_Children().get_Count(); i++) { SecurityElement securityElement3 = securityElement2.get_Children().get_Item(i) as SecurityElement; string text = securityElement3.Attribute("objectName"); string text2 = securityElement3.Attribute("id"); int num = int.Parse(text2); string text3 = securityElement3.Attribute("isTemp"); if (text3 == "false") { action.templateObjectIds.Add(text, num); } } } } return(action.templateObjectIds); }
void Start() { SecurityParser sp = new SecurityParser(); string s = Resources.Load("test").ToString(); sp.LoadXml(s); SecurityElement se = sp.ToXml(); foreach (SecurityElement child in se.Children) { //比对下是否使自己所需要得节点 if (child.Tag == "table") { //获得节点得属性 string wave = child.Attribute("wave"); string level = child.Attribute("level"); string name = child.Attribute("name"); Debug.Log("wave:" + wave + " level:" + level + " name:" + name); } } }
/// <summary> /// 加载关卡配置 /// </summary> /// <returns></returns> private void LoadLevelConfig() { // 加载配置 var resMgr = Game.GetManager <GResManager>(); var bundleName = "levels/scenes/" + m_levelName.ToLower(); var bundle = resMgr.LoadAssetBundle(bundleName); var mapTextAsset = bundle.LoadAsset("Map.xml") as TextAsset; SecurityParser parser = new SecurityParser(); parser.LoadXml(mapTextAsset.text); m_xml = parser.ToXml(); // navmesh var navmeshPrefab = bundle.LoadAsset("Navmesh.prefab") as GameObject; var navGo = GameObject.Instantiate(navmeshPrefab) as GameObject; navGo.transform.position = Vector3.zero; m_navMeshSurface = navGo.GetComponent <NavMeshSurface>(); m_navMeshSurface.layerMask = 1 << LayerMask.NameToLayer(LevelFunctionType.Ground.ToString()); resMgr.UnLoadAssetBundle(bundleName); }
public void ParseNoticeXML(string xml) { SecurityParser sp = new SecurityParser(); try { sp.LoadXml(xml); SecurityElement se = sp.ToXml(); foreach (SecurityElement child in se.Children) { if (child.Tag == "Content") { string contentNotice = child.Attribute("text"); string contentSwitch = child.Attribute("switch"); /*NoticeController nCtrl = UIManager.GetControler<NoticeController>(); * if (nCtrl != null) * { * nCtrl.setNoticeStr(contentNotice); * if (string.IsNullOrEmpty(contentSwitch) || contentSwitch == "0") * { * NoticeController.bSwitch = false; * } * else * { * NoticeController.bSwitch = true; * } * }*/ break; } } } catch (System.Exception ex) { Utils.LogSys.LogError(ex.Message); } }
IEnumerator RequestXml() { this.xmlLoader = new WWW(URLAntiCacheRandomizer.RandomURL(ServerAddress)); Debug.Log(xmlLoader.url); label.text = @"连接服务器中....."; yield return(this.xmlLoader); if (this.xmlLoader.error == null && this.xmlLoader.isDone) { SecurityParser xml = new SecurityParser(); xml.LoadXml(this.xmlLoader.text); Debug.Log(this.xmlLoader.text); label.text = @"服务器地址加载中"; SecurityElement root = xml.ToXml(); AllAdrList.InitList(root); StartCoroutine(check_update()); } else { label.text = @"服务器地址加载出错"; Debug.Log(this.xmlLoader.error); } StopCoroutine(RequestXml()); }
private void ReadXml(string xml) { workSheetList = new List <XmlWorksheet>(); SecurityParser parser = new SecurityParser(); parser.LoadXml(xml); SecurityElement rootElement = parser.ToXml(); foreach (SecurityElement childRoot in rootElement.Children) { if (childRoot.Tag.Equals("Worksheet")) { foreach (SecurityElement child in childRoot.Children) { if (child.Tag.Equals("Table")) { workSheetList.Add(new XmlWorksheet(m_xmlPath, child)); } } } } }
/// <summary> /// 返回线上连上的5个点 /// </summary> /// <returns>The points.</returns> /// <param name="index">Index.</param> protected int[] LinePoints(int index) { int[] iconIndex = new int[5]; //返回线上连上的5个点 SecurityParser sp = new SecurityParser(); string xmlPath = "XMLData/GameSlot"; Object xml = Resources.Load(xmlPath); sp.LoadXml(xml.ToString()); System.Security.SecurityElement se = sp.ToXml(); foreach (System.Security.SecurityElement child in se.Children) { if (int.Parse(child.Attribute("id")) == index) { iconIndex[0] = int.Parse(child.Attribute("offset1")) - 1; iconIndex[1] = int.Parse(child.Attribute("offset2")) - 1; iconIndex[2] = int.Parse(child.Attribute("offset3")) - 1; iconIndex[3] = int.Parse(child.Attribute("offset4")) - 1; iconIndex[4] = int.Parse(child.Attribute("offset5")) - 1; } } return(iconIndex); }
void ReadTheXml() { string xmlpath = "XMLData/linesBet"; xml = Resources.Load(xmlpath); SecurityParser sp = new SecurityParser(); sp.LoadXml(xml.ToString()); System.Security.SecurityElement se = sp.ToXml(); foreach (System.Security.SecurityElement child in se.Children) { if (SceneManager.lineCount == int.Parse(child.Attribute("gear"))) { int i = 0; LineGear.Add(int.Parse(child.Attribute("gear")), int.Parse(child.Attribute("delta"))); foreach (System.Security.SecurityElement cc in child.Children) { MoneyCountDelta[i] = double.Parse(cc.Text); i++; } } } LineGear.TryGetValue(SceneManager.lineCount, out LineCountDelta); }
private static bool LoadWorkspaceSetting(string file, string ext, ref string workspaceFile) { try { byte[] array = Workspace.ReadFileToBuffer(file, ext); if (array != null) { string @string = Encoding.get_UTF8().GetString(array); SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(@string); SecurityElement securityElement = securityParser.ToXml(); if (securityElement.get_Tag() == "workspace") { workspaceFile = securityElement.Attribute("path"); return(true); } } } catch (Exception ex) { string text = string.Format("Load Workspace {0} Error : {1}", file, ex.get_Message()); } return(false); }
/** * <?xml version="1.0" encoding="utf-8"?> * <behavior agenttype="AgentTest"> * <!--EXPORTED BY TOOL, DON'T MODIFY IT!-. * <!--Source File: ... -. * <node class="DecoratorLoopTask"> * <property Count="10" /> * <node class="SelectorTask"> * ... * </node> * </node> * </behavior> */ public bool load_xml(byte[] pBuffer) { try { Debug.Check(pBuffer != null); string xml = System.Text.Encoding.UTF8.GetString(pBuffer); SecurityParser xmlDoc = new SecurityParser(); xmlDoc.LoadXml(xml); SecurityElement behaviorNode = xmlDoc.ToXml(); if (behaviorNode.Tag != "behavior" && (behaviorNode.Children == null || behaviorNode.Children.Count != 1)) { return(false); } this.m_name = behaviorNode.Attribute("name"); string agentType = behaviorNode.Attribute("agenttype"); string versionStr = behaviorNode.Attribute("version"); int version = int.Parse(versionStr); this.SetClassNameString("BehaviorTree"); this.SetId(-1); this.load_properties_pars_attachments_children(true, version, agentType, behaviorNode); return(true); } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return(false); }
void ReadFile() { var sp = new SecurityParser(); sp.LoadXml(File.ReadAllText(file)); SecurityElement root = sp.ToXml(); if (root.Tag == "KeyPair") { SecurityElement keyvalue = root.SearchForChildByTag("KeyValue"); if (keyvalue.Children.Count == 0) { return; } KeyValue = keyvalue.Children [0].ToString(); SecurityElement properties = root.SearchForChildByTag("Properties"); if (properties.Children.Count == 0) { return; } SecurityElement property; string containerName = null, attribute; int providerType = -1; foreach (object o in properties.Children) { property = o as SecurityElement; if (property == null) { continue; } switch (property.Tag) { case "Provider": attribute = property.Attribute("Type"); if (String.IsNullOrEmpty(attribute)) { return; } if (!Int32.TryParse(attribute, out providerType)) { return; } break; case "Container": attribute = property.Attribute("Name"); if (String.IsNullOrEmpty(attribute)) { return; } containerName = attribute; break; } } if (String.IsNullOrEmpty(containerName) || providerType == -1) { return; } ContainerName = containerName; ProviderType = providerType; IsValid = true; } }
public TableData GetTableData(string tabName, string xmlText) { LogLine(tabName); List <SheetData> sheets = new List <SheetData>(); m_parser.LoadXml(xmlText); SecurityElement el_0 = m_parser.ToXml(); foreach (SecurityElement el_1 in el_0.Children) { if (sheets.Count >= m_maxSheetCheckCount) { break; } if (el_1.Tag != TAG_WORKSHEET) { continue; } string sheetname = el_1.Attributes[KEY_SHEET_NAME].ToString(); Log("├─" + sheetname); foreach (SecurityElement el_2 in el_1.Children) { if (el_2.Tag != TAG_TABLE || el_2.Children == null || el_2.Children.Count <= 0) { continue; } List <RowData> rows = new List <RowData>(); foreach (SecurityElement rowEl in el_2.Children) { if (rowEl.Tag != TAG_ROW || rowEl.Children == null || rowEl.Children.Count <= 0 || IsEmptyRow(rowEl)) { continue; } List <CellData> cells = new List <CellData>(); foreach (SecurityElement cellEl in rowEl.Children) { if (cellEl.Tag != TAG_CELL) { continue; } var idxStr = cellEl.Attribute(KEY_CELL_INDEX); if (!string.IsNullOrEmpty(idxStr)) { var index = int.Parse(idxStr); while (cells.Count < index - 1) { cells.Add(new CellData(rows.Count, cells.Count, "")); } } cells.Add(new CellData(rows.Count, cells.Count, GetCellData(cellEl))); } // 补齐行尾 while (rows.Count > 0 && cells.Count < rows[0].cells.Count) { cells.Add(new CellData(rows.Count, cells.Count, "")); } RowData row = new RowData(cells); rows.Add(row); } // Set Head for (int i = 3; i < rows.Count; i++) { for (int j = 0; j < rows[i].cells.Count; j++) { var cell = rows[i].cells[j]; string[] heads = new string[3]; for (int k = 0; k < 3; k++) { if (j < rows[k].cells.Count) { heads[k] = rows[k].cells[j].value; } } // name, type, desc cell.SetHead(heads[0], heads[1], heads[2]); } } if (rows.Count > 0) { sheets.Add(new SheetData(sheetname, rows)); } else { Log("(empty)"); } LogLine(); } } LogLine(); return(new TableData(tabName, sheets)); }
private static bool load_xml(byte[] pBuffer) { try { Debug.Check(pBuffer != null); string xml = System.Text.Encoding.UTF8.GetString(pBuffer); SecurityParser xmlDoc = new SecurityParser(); xmlDoc.LoadXml(xml); SecurityElement rootNode = xmlDoc.ToXml(); if (rootNode.Children == null || rootNode.Tag != "agents" && rootNode.Children.Count != 1) { return(false); } string versionStr = rootNode.Attribute("version"); Debug.Check(!string.IsNullOrEmpty(versionStr)); string signatureStr = rootNode.Attribute("signature"); checkSignature(signatureStr); foreach (SecurityElement bbNode in rootNode.Children) { if (bbNode.Tag == "agent" && bbNode.Children != null) { string agentType = bbNode.Attribute("type").Replace("::", "."); uint classId = Utils.MakeVariableId(agentType); AgentMeta meta = AgentMeta.GetMeta(classId); if (meta == null) { meta = new AgentMeta(); _agentMetas[classId] = meta; } foreach (SecurityElement propertiesNode in bbNode.Children) { if (propertiesNode.Tag == "properties" && propertiesNode.Children != null) { foreach (SecurityElement propertyNode in propertiesNode.Children) { if (propertyNode.Tag == "property") { string memberStr = propertyNode.Attribute("member"); bool bIsMember = (!string.IsNullOrEmpty(memberStr) && memberStr == "true"); if (!bIsMember) { string propName = propertyNode.Attribute("name"); string propType = propertyNode.Attribute("type").Replace("::", "."); string valueStr = propertyNode.Attribute("defaultvalue"); string isStatic = propertyNode.Attribute("static"); bool bIsStatic = (!string.IsNullOrEmpty(isStatic) && isStatic == "true"); registerCustomizedProperty(meta, propName, propType, valueStr, bIsStatic); } } } } } //end of for propertiesNode } } //end of for bbNode return(true); } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return(false); }
public static int[] AnimationConversion(int index, int form) { int[] iconIndex = new int[5]; //返回线上连上的5个点 SecurityParser sp = new SecurityParser(); string xmlPath = "XMLData/GameSlot"; Object xml = Resources.Load(xmlPath); sp.LoadXml(xml.ToString()); System.Security.SecurityElement se = sp.ToXml(); foreach (System.Security.SecurityElement child in se.Children) { if (int.Parse(child.Attribute("id")) == index) { iconIndex [0] = int.Parse(child.Attribute("offset1")) - 1; iconIndex [1] = int.Parse(child.Attribute("offset2")) - 1; iconIndex [2] = int.Parse(child.Attribute("offset3")) - 1; iconIndex [3] = int.Parse(child.Attribute("offset4")) - 1; iconIndex [4] = int.Parse(child.Attribute("offset5")) - 1; } } //根据form来返回需要播放特效的点 //左 3,左4,右3,右4,全部 switch (form) { case 1: showIconEffectIcon = new int[3]; for (int i = 0; i < 3; i++) { showIconEffectIcon [i] = iconIndex [i]; } break; case 2: showIconEffectIcon = new int[3]; for (int i = 0; i < 3; i++) { showIconEffectIcon [i] = iconIndex [i + 2]; } break; case 3: showIconEffectIcon = new int[4]; for (int i = 0; i < 4; i++) { showIconEffectIcon [i] = iconIndex [i]; } break; case 4: showIconEffectIcon = new int[4]; for (int i = 0; i < 4; i++) { showIconEffectIcon [i] = iconIndex [i + 1]; } break; case 5: showIconEffectIcon = new int[5]; for (int i = 0; i < 5; i++) { showIconEffectIcon [i] = iconIndex [i]; } break; default: break; } return(showIconEffectIcon); }
private void Parser(WWW www) { m_LoadOk = true; GuLog.Debug("MissionConfigPath WWW::" + www.error); if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); GuLog.Debug("MissionConfigPath" + www.text); xmlDoc.LoadXml(www.text); ArrayList worldXmlList = xmlDoc.ToXml().Children; foreach (SecurityElement xeWorld in worldXmlList) { if (xeWorld.Tag == "World") { WorldInfo worldInfo = new WorldInfo(); worldInfo.ID = Convert.ToInt32(xeWorld.Attribute("ID")); worldInfo.Type = WorldInfo.WorldTypes.Normal; int type = Convert.ToInt32(xeWorld.Attribute("Type")); if (Enum.IsDefined(typeof(WorldInfo.WorldTypes), type)) { worldInfo.Type = (WorldInfo.WorldTypes)type; } worldInfo.Name = xeWorld.Attribute("Name"); worldInfo.Title = xeWorld.Attribute("Title"); worldInfo.Photo = xeWorld.Attribute("Photo"); worldInfo.Preview = xeWorld.Attribute("Preview"); worldInfo.Unlock = xeWorld.Attribute("Unlock"); worldInfo.SleepBackgournd = xeWorld.Attribute("SleepBackgournd"); ArrayList sceneXmlList = xeWorld.Children; foreach (SecurityElement xeScene in sceneXmlList) { if (xeScene.Tag == "Scene") { SceneInfo sceneInfo = new SceneInfo(); sceneInfo.index = Convert.ToInt32(xeScene.Attribute("Index")); sceneInfo.strName = xeScene.Attribute("Name"); sceneInfo.TitleBg = xeScene.Attribute("TitleBg"); sceneInfo.TitleColor = xeScene.Attribute("TitleColor"); sceneInfo.Icon = xeScene.Attribute("Icon"); sceneInfo.BoxType = xeScene.Attribute("BoxType"); sceneInfo.Preview = xeScene.Attribute("Preview"); sceneInfo.Unlock = xeScene.Attribute("Unlock"); ArrayList storyXmlList = xeScene.Children; foreach (SecurityElement xeMission in storyXmlList) { if (xeMission.Tag == "Mission") { MissionInfo story = new MissionInfo(); story.missionId = Convert.ToInt32(xeMission.Attribute("Id")); story.QuestId = Convert.ToInt32(xeMission.Attribute("QuestId")); story.strBackground = xeMission.Attribute("Background"); story.strModel = xeMission.Attribute("Model"); story.NimIcon = xeMission.Attribute("NimIcon"); story.MissionName = xeMission.Attribute("Name"); story.dailyGoalPercent = Convert.ToSingle(xeMission.Attribute("dailyGoalPercent")); story.AwardCoin = Convert.ToInt32(xeMission.Attribute("AwardCoin")); story.Sound = xeMission.Attribute("Sound"); story.BGM = xeMission.Attribute("BGM"); story.WaterDrop = xeMission.Attribute("WaterDrop"); story.WaterDropAudio = xeMission.Attribute("WaterDropAudio"); ArrayList treasureBoxXmlList = xeMission.Children; foreach (SecurityElement xeTreasure in treasureBoxXmlList) { if (xeTreasure.Tag == "TreasureBox") { MissionTreasureBox treasure = new MissionTreasureBox(); treasure.BoxId = Convert.ToInt32(xeTreasure.Attribute("BoxId")); treasure.Height = Convert.ToInt32(xeTreasure.Attribute("Height")); story.listTreasureBox.Add(treasure); } } sceneInfo.missionInfos.Add(story); } } worldInfo.SceneInfos.Add(sceneInfo); } } worldInfos.Add(worldInfo); } } } GuLog.Debug("LoadMissionConfig OK! World:" + worldInfos.Count); GuLog.Debug("SceneCount" + worldInfos[0].SceneInfos.Count); GuLog.Debug("MissionCount" + worldInfos[0].SceneInfos[0].missionInfos.Count); }
/************************************************私 有 方 法************************************************/ //读取语言配置文件 private void Parser(WWW www) { m_LoadOk = true; GuLog.Debug("AccessoryConfigParser WWW:" + www.error); if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); GuLog.Debug("AccessoryConfigParser: " + www.text); xmlDoc.LoadXml(www.text); ArrayList allNodes = xmlDoc.ToXml().Children; foreach (SecurityElement xeResConfigs in allNodes) { //根节点 if (xeResConfigs.Tag == "Accessories") { //Accessories点 ArrayList accessoryConfigNodes = xeResConfigs.Children; foreach (SecurityElement xeAccessory in accessoryConfigNodes) {//Accessory节点 if (xeAccessory.Tag == "Accessory") { Accessory accessory = new Accessory() { ID = Convert.ToInt32(xeAccessory.Attribute("ID")), Type = Convert.ToInt32(xeAccessory.Attribute("Type")), Index = Convert.ToInt32(xeAccessory.Attribute("Index")), Name = xeAccessory.Attribute("Name"), Icon = xeAccessory.Attribute("Icon"), AB = xeAccessory.Attribute("AB"), Prefab = xeAccessory.Attribute("Prefab"), Region = xeAccessory.Attribute("Region"), Purchase = xeAccessory.Attribute("Purchase"), Price = Convert.ToSingle(xeAccessory.Attribute("Price")), StartTime = DateTime.MaxValue, EndTime = DateTime.MaxValue, Level = Convert.ToInt32(xeAccessory.Attribute("Level")), Exp = Convert.ToInt32(xeAccessory.Attribute("Exp")), PURPIE = xeAccessory.Attribute("PURPIE") == "1", DONNY = xeAccessory.Attribute("DONNY") == "1", NINJI = xeAccessory.Attribute("NINJI") == "1", SANSA = xeAccessory.Attribute("SANSA") == "1", YOYO = xeAccessory.Attribute("YOYO") == "1", NUO = xeAccessory.Attribute("NUO") == "1" }; DateTime dateTime = DateTime.MaxValue; if (DateTime.TryParse(xeAccessory.Attribute("StartTime"), out dateTime)) { accessory.StartTime = dateTime; } if (DateTime.TryParse(xeAccessory.Attribute("EndTime"), out dateTime)) { accessory.EndTime = dateTime; } this.accessories.Add(accessory); } } } } //GuLog.Debug(string.Format("<><AccessoryConfig.Parser>Accessory.xml: {0}", www.text)); } }
/// <summary> /// Reconstructs a <see cref="DiffieHellman"/> object from an XML string. /// </summary> /// <param name="xmlString">The XML string to use to reconstruct the DiffieHellman object.</param> /// <exception cref="CryptographicException">One of the values in the XML string is invalid.</exception> public override void FromXmlString(string xmlString) { if (xmlString == null) throw new ArgumentNullException(); DHParameters dhParams = new DHParameters(); try { SecurityParser sp = new SecurityParser(); sp.LoadXml(xmlString); SecurityElement se = sp.ToXml(); if (se.Tag != "DHKeyValue") throw new CryptographicException(); dhParams.P = GetNamedParam(se, "P"); dhParams.G = GetNamedParam(se, "G"); dhParams.X = GetNamedParam(se, "X"); ImportParameters(dhParams); } finally { if (dhParams.P != null) Array.Clear(dhParams.P, 0, dhParams.P.Length); if (dhParams.G != null) Array.Clear(dhParams.G, 0, dhParams.G.Length); if (dhParams.X != null) Array.Clear(dhParams.X, 0, dhParams.X.Length); } }