public 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); } }
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); } }
/// <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); }
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)); } } } } }
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); }
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); }
/// <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); } } }
/** * <?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); }
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 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)); } }
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); }
public Action LoadActionResource(string _actionName) { Action action = null; if (_actionName == null) { DebugHelper.Assert(_actionName != null, "can't load action with name = null"); return(null); } if (this.actionResourceSet.TryGetValue(_actionName, out action)) { if (action != null) { return(action); } this.actionResourceSet.Remove(_actionName); } CBinaryObject cBinaryObject = ActionManager.Instance.resLoader.LoadAge(_actionName) as CBinaryObject; if (cBinaryObject == null) { return(null); } SecurityParser securityParser = new SecurityParser(); try { securityParser.LoadXml(Encoding.get_UTF8().GetString(cBinaryObject.m_data)); } catch (Exception ex) { DebugHelper.Assert(false, "Load xml Exception for action name = {0}, exception = {1}", new object[] { _actionName, ex.get_Message() }); return(null); } action = new Action(); action.name = _actionName; action.enabled = false; action.actionName = _actionName; this.actionResourceSet.Add(_actionName, action); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(_actionName); SecurityElement securityElement = securityParser.SelectSingleNode("Project"); SecurityElement securityElement2 = (securityElement != null) ? securityElement.SearchForChildByTag("TemplateObjectList") : null; SecurityElement securityElement3 = (securityElement != null) ? securityElement.SearchForChildByTag("Action") : null; SecurityElement securityElement4 = (securityElement != null) ? securityElement.SearchForChildByTag("RefParamList") : null; DebugHelper.Assert(securityElement3 != null, "actionNode!=null"); if (securityElement3 != null) { action.length = ActionUtility.SecToMs(float.Parse(securityElement3.Attribute("length"))); action.loop = bool.Parse(securityElement3.Attribute("loop")); } if (securityElement2 != null && securityElement2.get_Children() != null) { for (int i = 0; i < securityElement2.get_Children().get_Count(); i++) { SecurityElement securityElement5 = securityElement2.get_Children().get_Item(i) as SecurityElement; string str = securityElement5.Attribute("objectName"); string text = securityElement5.Attribute("id"); int id = int.Parse(text); action.AddTemplateObject(str, id); } } if (securityElement4 != null && securityElement4.get_Children() != null) { for (int j = 0; j < securityElement4.get_Children().get_Count(); j++) { this.LoadRefParamNode(action, securityElement4.get_Children().get_Item(j) as SecurityElement); } } if (securityElement3 != null && securityElement3.get_Children() != null) { for (int k = 0; k < securityElement3.get_Children().get_Count(); k++) { SecurityElement securityElement6 = securityElement3.get_Children().get_Item(k) as SecurityElement; string text2 = securityElement6.Attribute("eventType"); if (!text2.Contains(".") && text2.get_Length() > 0) { text2 = "AGE." + text2; } Type type = Utility.GetType(text2); if (type != null) { string name = string.Empty; bool flag = false; if (securityElement6.Attribute("refParamName") != null) { name = securityElement6.Attribute("refParamName"); } if (securityElement6.Attribute("useRefParam") != null) { flag = bool.Parse(securityElement6.Attribute("useRefParam")); } bool enabled = bool.Parse(securityElement6.Attribute("enabled")); if (flag) { action.refParams.GetRefParam(name, ref enabled); } Track track = action.AddTrack(type); track.enabled = enabled; track.trackName = securityElement6.Attribute("trackName"); if (securityElement6.Attribute("execOnActionCompleted") != null) { track.execOnActionCompleted = bool.Parse(securityElement6.Attribute("execOnActionCompleted")); } if (securityElement6.Attribute("execOnForceStopped") != null) { track.execOnForceStopped = bool.Parse(securityElement6.Attribute("execOnForceStopped")); } if (flag) { FieldInfo field = type.GetField(securityElement6.Attribute("enabled")); action.refParams.AddRefData(name, field, track); } if (securityElement6.Attribute("r") != null) { track.color.r = float.Parse(securityElement6.Attribute("r")); } if (securityElement6.Attribute("g") != null) { track.color.g = float.Parse(securityElement6.Attribute("g")); } if (securityElement6.Attribute("b") != null) { track.color.b = float.Parse(securityElement6.Attribute("b")); } ListView <SecurityElement> listView = new ListView <SecurityElement>(); if (securityElement6.get_Children() != null) { for (int l = 0; l < securityElement6.get_Children().get_Count(); l++) { SecurityElement securityElement7 = securityElement6.get_Children().get_Item(l) as SecurityElement; if (securityElement7.get_Tag() != "Event" && securityElement7.get_Tag() != "Condition") { listView.Add(securityElement7); } } for (int m = 0; m < securityElement6.get_Children().get_Count(); m++) { SecurityElement securityElement8 = securityElement6.get_Children().get_Item(m) as SecurityElement; if (securityElement8.get_Tag() == "Condition") { SecurityElement securityElement9 = securityElement8; int num = int.Parse(securityElement9.Attribute("id")); bool flag2 = bool.Parse(securityElement9.Attribute("status")); if (track.waitForConditions == null) { track.waitForConditions = new Dictionary <int, bool>(); } track.waitForConditions.Add(num, flag2); } else if (!(securityElement8.get_Tag() != "Event")) { int time = ActionUtility.SecToMs(float.Parse(securityElement8.Attribute("time"))); int length = 0; if (track.IsDurationEvent) { length = ActionUtility.SecToMs(float.Parse(securityElement8.Attribute("length"))); } BaseEvent baseEvent = track.AddEvent(time, length); for (int n = 0; n < listView.Count; n++) { this.SetEventField(action, baseEvent, listView[n]); } if (securityElement8.get_Children() != null) { for (int num2 = 0; num2 < securityElement8.get_Children().get_Count(); num2++) { this.SetEventField(action, baseEvent, securityElement8.get_Children().get_Item(num2) as SecurityElement); } } baseEvent.OnLoaded(); } } } } else { Debug.LogError("Invalid event type \"" + securityElement6.Attribute("eventType") + "\"!"); } } } return(action); }
public bool GetActionTemplateObjectsAndPredefRefParams(string actionName, ref List <TemplateObject> objs, ref List <string> refnames) { if (actionName == null) { return(false); } ActionCommonData actionCommonData; if (this.actionCommonDataSet.ContainsKey(actionName)) { actionCommonData = this.actionCommonDataSet[actionName]; } else { CBinaryObject cBinaryObject = ActionManager.Instance.resLoader.LoadAge(actionName) as CBinaryObject; if (cBinaryObject == null) { return(false); } actionCommonData = new ActionCommonData(); 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) { using (IEnumerator enumerator = securityElement2.get_Children().GetEnumerator()) { while (enumerator.MoveNext()) { SecurityElement securityElement3 = (SecurityElement)enumerator.get_Current(); if (!(securityElement3.get_Tag() != "TemplateObject")) { TemplateObject templateObject = new TemplateObject(); templateObject.name = securityElement3.Attribute("objectName"); templateObject.id = int.Parse(securityElement3.Attribute("id")); templateObject.isTemp = bool.Parse(securityElement3.Attribute("isTemp")); actionCommonData.templateObjects.Add(templateObject); } } } } SecurityElement securityElement4 = (securityElement != null) ? securityElement.SearchForChildByTag("RefParamList") : null; if (securityElement4 != null) { using (IEnumerator enumerator2 = securityElement4.get_Children().GetEnumerator()) { while (enumerator2.MoveNext()) { SecurityElement securityElement5 = (SecurityElement)enumerator2.get_Current(); string text = securityElement5.Attribute("name"); if (text.StartsWith("_")) { actionCommonData.predefRefParamNames.Add(text); } } } } this.actionCommonDataSet.Add(actionName, actionCommonData); } if (actionCommonData != null) { objs.Clear(); refnames.Clear(); for (int i = 0; i < actionCommonData.templateObjects.Count; i++) { objs.Add(actionCommonData.templateObjects[i]); } for (int j = 0; j < actionCommonData.predefRefParamNames.Count; j++) { refnames.Add(actionCommonData.predefRefParamNames[j]); } } return(true); }
private IDictionary LoadTableWithSecurityParser(Type tableType, string content) { IDictionary dict = null; Hashtable typeMap = null; SecurityParser parser = new SecurityParser(); parser.LoadXml(content); SecurityElement element = parser.ToXml(); for (int i = 0; i < element.Children.Count; i++) { SecurityElement subElement = element.Children[i] as SecurityElement; if (subElement.Tag == TAG_TYPE) { #region type line SecurityElement item = subElement.Children[0] as SecurityElement; if (item.Tag == TAG_ITEM) { typeMap = item.Attributes; if (typeMap["id"].ToString() == "int") { dict = new Dictionary <int, object>(); } else if (typeMap["id"].ToString() == "string") { dict = new Dictionary <string, object>(); } else { Logger.LogError("wrong ID type : " + typeMap["id"]); } } else { Logger.LogError("The TAG " + item.Tag + " is not a valid Tag"); } #endregion } else if (subElement.Tag == TAG_DATA) { for (int j = 0; subElement.Children != null && j < subElement.Children.Count; j++) { SecurityElement item = subElement.Children[j] as SecurityElement; if (item.Tag == TAG_ITEM) { Hashtable hashTable = item.Attributes; Hashtable paramMap = new Hashtable(); var itr = hashTable.GetEnumerator(); while (itr.MoveNext()) { string key = itr.Key.ToString(); string value = itr.Value.ToString(); string type = typeMap[key].ToString(); paramMap.Add(key, ParseValue(type, value)); } object obj = Activator.CreateInstance(tableType, paramMap); object id = ParseValue(typeMap["id"].ToString(), hashTable["id"].ToString()); if (dict.Contains(id)) { Logger.LogError("Table has the repeat ID : " + tableType + " --> " + id); } else { dict.Add(id, obj); } } else { Logger.LogError("The TAG " + item.Tag + " is not a valid Tag"); } } } else { Logger.LogError("The TAG " + subElement.Tag + " is not a valid Tag"); } } return(dict); }
public MonoXmlParse() { m_Sp = new SecurityParser(); }
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); }
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; } }
private void InitHelper(string filecContent) { //string xml = MGFileUtil.LoadXml(file); this.xmlDoc = new SecurityParser(); this.xmlDoc.LoadXml(filecContent); }
private void Parser(WWW www) { try { GuLog.Debug("LevelConfigPath WWW::" + www.error); if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); GuLog.Debug("LevelConfigPath" + www.text); xmlDoc.LoadXml(www.text); ArrayList worldXmlList = xmlDoc.ToXml().Children; foreach (SecurityElement xeRoot in worldXmlList) { if (xeRoot.Tag == "Levels") { ArrayList levelsXmlList = xeRoot.Children; foreach (SecurityElement xeLevel in levelsXmlList) { if (xeLevel.Tag == "LevelUp") { LevelInfo levelInfo = new LevelInfo(); levelInfo.level = Convert.ToInt32(xeLevel.Attribute("level")); levelInfo.exp = Convert.ToInt32(xeLevel.Attribute("exp")); levelInfo.hunger = Convert.ToInt32(xeLevel.Attribute("hunger")); levelInfo.coinDL = Convert.ToInt32(xeLevel.Attribute("coinDL")); levelInfo.coinUL = Convert.ToInt32(xeLevel.Attribute("coinUL")); ArrayList awardXmlList = xeLevel.Children; foreach (SecurityElement xeAward in awardXmlList) { switch (xeAward.Tag) { case "DrinkWater": levelInfo.awardList.Add(new DrinkWater() { CoinDL = Convert.ToInt32(xeAward.Attribute("coinDL")), CoinUL = Convert.ToInt32(xeAward.Attribute("coinUL")), ExpNormal = Convert.ToInt32(xeAward.Attribute("expN")), ExpGoal = Convert.ToInt32(xeAward.Attribute("expG")), Rate30 = (float)Convert.ToDouble(xeAward.Attribute("rate30")), RateMore = (float)Convert.ToDouble(xeAward.Attribute("rateMore")) }); break; case "DailyGoal": levelInfo.awardList.Add(new DailyGoal() { Percent = (float)Convert.ToDouble(xeAward.Attribute("percent")), Coin = Convert.ToInt32(xeAward.Attribute("coin")), Award = Convert.ToInt32(xeAward.Attribute("award")), ExpDL = Convert.ToInt32(xeAward.Attribute("expDL")), ExpUL = Convert.ToInt32(xeAward.Attribute("expUL")) }); break; } } levelLists.Add(levelInfo.level, levelInfo); } } } } } } catch (Exception ex) { Debug.LogErrorFormat("<><LevelConfig.Parser>Error: {0}", ex.Message); } m_LoadOk = true; }
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); }
/// <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 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); }
public XML() { _parser = new SecurityParser(); }
//----------------------------------------------------------------------------------- //解析xml数据 static public VersionInfo ParseData(string xmlContent) { VersionInfo versionInfo = new VersionInfo(); try { SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(xmlContent); SecurityElement xml = securityParser.ToXml(); if (xml == null) { Debug.LogError("VersionInfo.ParseData:XML Data Error"); return(versionInfo); } if (xml.Children == null || xml.Children.Count == 0) { return(versionInfo); } foreach (SecurityElement se in xml.Children) { string tag = se.Tag.ToLower(); switch (tag) { case "programversion": versionInfo.ProgramVersion = float.Parse(se.Text); break; case "apkurl": versionInfo.ApkUrl = se.Text; break; case "apkmd5": versionInfo.ApkMd5 = se.Text; break; case "iosappurl": versionInfo.IOSAppUrl = se.Text; break; case "iosappstoreurl": versionInfo.IOSAppStoreUrl = se.Text; break; case "isappleappstore": versionInfo.IsAppleAppStore = StrBoolParse(se.Text); break; case "isopenautoupdateinappstore": versionInfo.IsOpenAutoUpdateInAppStore = StrBoolParse(se.Text); break; case "isforcetoupdate": versionInfo.IsForceToUpdate = StrBoolParse(se.Text); break; case "resinfo": { if (se.Children == null || se.Children.Count == 0) { continue; } foreach (SecurityElement record in se.Children) { if (record.Children == null || record.Children.Count == 0) { continue; } ResInfo resInfo = new ResInfo(); foreach (SecurityElement node in record.Children) { string resTag = node.Tag.ToLower(); switch (resTag) { case "resname": resInfo.resName = node.Text; break; case "resmd5": resInfo.resMD5 = node.Text; break; case "ressize": resInfo.resSize = int.Parse(node.Text); break; case "resurl": resInfo.resURL = node.Text; break; case "resrequire": { if (node.Text == "0") { resInfo.isResRequire = false; } else if (node.Text == "1") { resInfo.isResRequire = true; } else { resInfo.isResRequire = bool.Parse(node.Text); } } break; case "resrequireid": resInfo.resRequireID = int.Parse(node.Text); break; } } if (versionInfo.dictRes.ContainsKey(resInfo.resName) == false) { versionInfo.dictRes.Add(resInfo.resName, resInfo); } else { string strError = string.Format("VersionInfo.ParseData:更新资源包名{0}重复", resInfo.resName); Debug.LogError(strError); } } } break; } } } catch (System.Exception ex) { Debug.LogException(ex); } return(versionInfo); }
/************************************************私 有 方 法************************************************/ //读取语言配置文件 private void Parser(WWW www) { m_LoadOk = true; GuLog.Debug("ResConfigPath WWW::" + www.error); if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); GuLog.Debug("ResConfigPath" + www.text); xmlDoc.LoadXml(www.text); ArrayList allNodes = xmlDoc.ToXml().Children; foreach (SecurityElement xeResConfigs in allNodes) { //根节点 if (xeResConfigs.Tag == "ResConfigs") { //ResConfigs节点 ArrayList resConfigNodes = xeResConfigs.Children; foreach (SecurityElement xeResConfig in resConfigNodes) {//ResConfig节点 if (xeResConfig.Tag == "ResConfig") { string language = xeResConfig.Attribute("Language"); if (this.LanConfig.IsValid(language)) { ResConfig resConfig = new ResConfig() { Language = language }; ArrayList elementNodes = xeResConfig.Children; foreach (SecurityElement xeText in elementNodes) { if (xeText.Tag == "Text") {//TextElement节点 TextElement textElement = new TextElement() { Key = xeText.Attribute("Key"), Value = xeText.Attribute("Value") }; resConfig.TextElements.Add(textElement); } else if (xeText.Tag == "Image") {//ImageElement节点 ImageElement imageElement = new ImageElement() { Key = xeText.Attribute("Key"), Value = xeText.Attribute("Value") }; resConfig.ImageElements.Add(imageElement); } else if (xeText.Tag == "Animation") {//AnimationElement节点 AnimationElement animationElement = new AnimationElement() { Key = xeText.Attribute("Key"), Value = xeText.Attribute("Value") }; resConfig.AnimationElements.Add(animationElement); } else if (xeText.Tag == "Audio") {//AudioElement节点 AudioElement audioElement = new AudioElement() { Key = xeText.Attribute("Key"), Value = xeText.Attribute("Value") }; resConfig.AudioElements.Add(audioElement); } } this.resConfigs.Add(language, resConfig); } else { GuLog.Error(string.Format("----I18NConfig.Parser----ResConfigs.Language: {0}", language)); } } } } } //GuLog.Debug(string.Format("----I18NConfig.Parser----I18NConfig.xml: {0}", www.text)); } }
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 xeWorld in worldXmlList) { if (xeWorld.Tag == "Items") { ArrayList sceneXmlList = xeWorld.Children; foreach (SecurityElement xeScene in sceneXmlList) { if (xeScene.Tag == "Item") { Item sceneInfo = null; int type = Convert.ToInt32(xeScene.Attribute("Type")); switch (type) { case 4: { NimItem nimInfo = new NimItem(); nimInfo.ItemId = Convert.ToInt32(xeScene.Attribute("Id")); nimInfo.Type = type; nimInfo.Name = xeScene.Attribute("Name"); nimInfo.GetImage = xeScene.Attribute("getImage"); nimInfo.PetType = int.Parse(xeScene.Attribute("PetType")); nimInfo.Image = xeScene.Attribute("Image"); nimInfo.Audio = xeScene.Attribute("Audio"); nimInfo.Animation = xeScene.Attribute("Animation"); nimInfo.Preview = xeScene.Attribute("Preview"); sceneInfo = nimInfo; } break; case 6: { PropsItem propsItem = new PropsItem(); propsItem.ItemId = Convert.ToInt32(xeScene.Attribute("Id")); propsItem.Type = type; propsItem.Name = xeScene.Attribute("Name"); propsItem.GetImage = xeScene.Attribute("getImage"); sceneInfo = propsItem; } break; default: { sceneInfo = new Item(); sceneInfo.ItemId = Convert.ToInt32(xeScene.Attribute("Id")); sceneInfo.Type = type; sceneInfo.Name = xeScene.Attribute("Name"); } break; } missionInfo.Add(sceneInfo.ItemId, sceneInfo); } } } } } }
public static void Execute() { if (!System.IO.Directory.Exists(ProtoDir)) { System.IO.Directory.CreateDirectory(ProtoDir); } var protoCfgPath = GetProtoConfigPath(); if (string.IsNullOrEmpty(protoCfgPath)) { UnityEngine.Debug.LogError("未找到protocol配置文件"); return; } sb = new StringBuilder(); string text = System.IO.File.ReadAllText(protoCfgPath); var parser = new SecurityParser(); parser.LoadXml(text); var xml = parser.ToXml(); foreach (SecurityElement child in xml.Children) { switch (child.Tag) { case "custom_type": foreach (SecurityElement structNode in child.Children) { var typeName = structNode.Attribute("name"); ParseStruct(structNode, typeName); System.IO.File.WriteAllText(ProtoDir + typeName + ".lua", sb.ToString()); sb.Length = 0; } break; case "section": string strModuleID = child.Attribute("id"); int moduleID = int.Parse(strModuleID); foreach (SecurityElement msgNode in child.Children) { ParseMessage(msgNode, moduleID); } System.IO.File.WriteAllText (ProtoDir + child.Attribute("name") + "_" + strModuleID + ".lua", sb.ToString()); sb.Length = 0; break; } } sb.Length = 0; var manifestName = "ProtoManifest.lua"; foreach (var f in System.IO.Directory.GetFiles(ProtoDir, "*.lua")) { if (!f.EndsWith(manifestName)) { var path = f.Replace("\\", "/"); int index0 = path.LastIndexOf("/"); int index1 = path.LastIndexOf("."); sb.AppendFormat("require('Protos/{0}')\n", path.Substring(index0 + 1, index1 - index0 - 1)); } } System.IO.File.WriteAllText(ProtoDir + manifestName, sb.ToString()); sb = null; UnityEngine.Debug.Log("协议导出成功!"); }
public ClientGeneratorModel BuildModel() { warnings = new Dictionary<string, string>(); classesNames = new Collection<string>(); classes = new Collection<ClassObject>(); classesObjectsRegistry = new Dictionary<string, ClassObject>(); uriParameterObjects = new Dictionary<string, ApiObject>(); enums = new Dictionary<string, ApiEnum>(); var ns = NetNamingMapper.GetNamespace(raml.Title); new RamlTypeParser(raml.Types, schemaObjects, ns, enums, warnings).Parse(); ParseSchemas(); schemaRequestObjects = GetRequestObjects(); schemaResponseObjects = GetResponseObjects(); CleanProperties(schemaObjects); CleanProperties(schemaRequestObjects); CleanProperties(schemaResponseObjects); clientMethodsGenerator = new ClientMethodsGenerator(raml, schemaResponseObjects, uriParameterObjects, queryObjects, headerObjects, responseHeadersObjects, schemaRequestObjects, linkKeysWithObjectNames, schemaObjects); var parentClass = new ClassObject { Name = rootClassName, Description = "Main class for grouping root resources. Nested resources are defined as properties. The constructor can optionally receive an URL and HttpClient instance to override the default ones." }; classesNames.Add(parentClass.Name); classes.Add(parentClass); classesObjectsRegistry.Add(rootClassName, parentClass); var classObjects = GetClasses(raml.Resources, null, parentClass, null, new Dictionary<string, Parameter>()); SetClassesProperties(classesObjectsRegistry[rootClassName]); var apiRequestObjects = apiRequestGenerator.Generate(classObjects); var apiResponseObjects = apiResponseGenerator.Generate(classObjects); CleanNotUsedObjects(classObjects); return new ClientGeneratorModel { Namespace = ns, SchemaObjects = schemaObjects, RequestObjects = schemaRequestObjects, ResponseObjects = schemaResponseObjects, QueryObjects = queryObjects, HeaderObjects = headerObjects, ApiRequestObjects = apiRequestObjects.ToArray(), ApiResponseObjects = apiResponseObjects.ToArray(), ResponseHeaderObjects = responseHeadersObjects, BaseUriParameters = ParametersMapper.Map(raml.BaseUriParameters).ToArray(), BaseUri = raml.BaseUri, Security = SecurityParser.GetSecurity(raml), Version = raml.Version, Warnings = warnings, Classes = classObjects.Where(c => c.Name != rootClassName).ToArray(), Root = classObjects.First(c => c.Name == rootClassName), UriParameterObjects = uriParameterObjects, Enums = Enums.ToArray() }; }
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.Tag != "agents" && (rootNode.Children == null || rootNode.Children.Count != 1)) { return(false); } string versionStr = rootNode.Attribute("version"); Debug.Check(!string.IsNullOrEmpty(versionStr)); foreach (SecurityElement bbNode in rootNode.Children) { if (bbNode.Tag == "agent" && bbNode.Children != null) { string agentType = bbNode.Attribute("type").Replace("::", "."); AgentProperties bb = new AgentProperties(agentType); agent_type_blackboards[agentType] = bb; foreach (SecurityElement propertiesNode in bbNode.Children) { if (propertiesNode.Tag == "properties" && propertiesNode.Children != null) { foreach (SecurityElement propertyNode in propertiesNode.Children) { if (propertyNode.Tag == "property") { string name = propertyNode.Attribute("name"); string type = propertyNode.Attribute("type").Replace("::", "."); string memberStr = propertyNode.Attribute("member"); bool bIsMember = false; if (!string.IsNullOrEmpty(memberStr) && memberStr == "true") { bIsMember = true; } string isStatic = propertyNode.Attribute("static"); bool bIsStatic = false; if (!string.IsNullOrEmpty(isStatic) && isStatic == "true") { bIsStatic = true; } //string agentTypeMember = agentType; string agentTypeMember = null; string valueStr = null; if (!bIsMember) { valueStr = propertyNode.Attribute("defaultvalue"); } else { agentTypeMember = propertyNode.Attribute("agent").Replace("::", "."); } bb.AddProperty(type, bIsStatic, name, valueStr, agentTypeMember); } } } else if (propertiesNode.Tag == "methods" && propertiesNode.Children != null) { Agent.CTagObjectDescriptor objectDesc = Agent.GetDescriptorByName(agentType); foreach (SecurityElement methodNode in propertiesNode.Children) { if (methodNode.Tag == "method") { //string eventStr = methodNode.Attribute("isevent"); //bool bEvent = (eventStr == "true"); //string taskStr = methodNode.Attribute("istask"); //bool bTask = (taskStr == "true"); //skip those other custom method string methodName = methodNode.Attribute("name"); //string type = methodNode.Attribute("returntype").Replace("::", "."); //string isStatic = methodNode.Attribute("static"); //string agentTypeStr = methodNode.Attribute("agent").Replace("::", "."); CCustomMethod customeMethod = new CTaskMethod(agentType, methodName); if (methodNode.Children != null) { foreach (SecurityElement paramNode in methodNode.Children) { if (paramNode.Tag == "parameter") { string paramName = paramNode.Attribute("name"); Debug.Check(!string.IsNullOrEmpty(paramName)); string paramType = paramNode.Attribute("type"); //string paramFullName = string.Format("{0}::{1}", paramType, paramName); customeMethod.AddParamType(paramType); } } } objectDesc.ms_methods.Add(customeMethod); } } //end of for methodNode } //end of methods } //end of for propertiesNode } } //end of for bbNode return(true); } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return(false); }