public void TestFriendsListInvites() { string xml = @"<roar tick=""135510457230""> <friends> <list_invites status=""ok""> <invite invite_id=""123"" from_player_id=""133"" from_player=""killah"" message""me so lonely""/> <invite invite_id=""124"" from_player_id=""155"" from_player=""healah"" message=""gold plz""/> </list_invites> </friends> </roar>" ; IXMLNode nn = (new XMLNode.XMLParser()).Parse(xml); Roar.WebObjects.Friends.ListInvitesResponse response = new Roar.DataConversion.Responses.Friends.ListInvites().Build(nn); Assert.IsNotNull(response); Assert.AreEqual(response.invites.Count, 2); Assert.AreEqual(response.invites[0].invite_id, "123"); Assert.AreEqual(response.invites[1].invite_id, "456"); Assert.AreEqual(response.invites[0].player_id, "19000494933"); Assert.AreEqual(response.invites[1].player_id, "90210"); Assert.AreEqual(response.invites[0].player_name, "killah"); Assert.AreEqual(response.invites[1].player_name, "healah"); Assert.AreEqual(response.invites[0].message, "me so lonely"); Assert.AreEqual(response.invites[1].message, "gold plz"); }
public ImmutableDataWellapadTask(string id, IXMLNode xmlNode, string errorMessage) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); // set id taskID = id; // get the task completion name -- fallback to the id taskName = XMLUtils.GetString(hashElements["Name"] as IXMLNode, "", errorMessage); // get the mission type taskType = XMLUtils.GetString(hashElements["Type"] as IXMLNode, "Side", errorMessage); // get the category of this task taskCategory = XMLUtils.GetString(hashElements["Category"] as IXMLNode, "", errorMessage); // get the amounts(optional) if (hashElements.ContainsKey("CompleteConditions")) { completeConditions = new List <int>(); string strAmounts = XMLUtils.GetString(hashElements["CompleteConditions"] as IXMLNode); string[] arrayAmounts = strAmounts.Split(","[0]); for (int i = 0; i < arrayAmounts.Length; ++i) { completeConditions.Add(int.Parse(arrayAmounts[i])); } } }
public NinjaData(string id, Hashtable hashAttr, IXMLNode nodeEntries, string strError) { // set id strID = id; // get the weight for this group string strWeight = HashUtils.GetHashValue <string>(hashAttr, "Weight", "1"); nWeight = int.Parse(strWeight); // get the scoring categories string strScoring = HashUtils.GetHashValue <string>(hashAttr, "Scoring", "Med", strError); string[] arrayScoring = strScoring.Split(","[0]); for (int i = 0; i < arrayScoring.Length; ++i) { NinjaScoring eScoring = (NinjaScoring)System.Enum.Parse(typeof(NinjaScoring), arrayScoring[i]); listScoring.Add(eScoring); } // go through the list of entries and add them to our list List <IXMLNode> listEntries = XMLUtils.GetChildrenList(nodeEntries); for (int i = 0; i < listEntries.Count; ++i) { Hashtable hashEntryAttr = XMLUtils.GetAttributes(listEntries[i]); NinjaDataEntry entry = new NinjaDataEntry(hashEntryAttr, strError); this.listEntries.Add(entry); } }
/// <summary> /// Probably need type information for each binding how to handle plural, and possession cases. /// </summary> public static string FormatString(Type classType, IXMLNode stringBindings) { List <PropertyInfo> propertyInfo = new List <PropertyInfo>(); Hashtable hashAttr = XMLUtils.GetAttributes(stringBindings); string stringFormat = ""; if (hashAttr.ContainsKey("StringFormat")) { stringFormat = (string)hashAttr["StringFormat"]; } else { Debug.LogError("string to be formatted can't be found for class " + classType); } //Localize the string string baseString = Localization.Localize(stringFormat); //Get all the bindings List <IXMLNode> childrenList = XMLUtils.GetChildrenList(stringBindings); foreach (IXMLNode node in childrenList) { Hashtable bindingAttr = XMLUtils.GetAttributes(node); string binding = (string)bindingAttr["Path"]; propertyInfo.Add(classType.GetProperty(binding)); } //format the base string with the format items return(string.Format(baseString, propertyInfo)); }
public ImmutableDataPartition(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; number = XMLUtils.GetInt(hashElements["Number"] as IXMLNode, 0, error); zone = (ZoneTypes)Enum.Parse(typeof(ZoneTypes), XMLUtils.GetString(hashElements["Zone"] as IXMLNode, null, error)); position = StringUtils.ParseVector3(XMLUtils.GetString(hashElements["Position"] as IXMLNode, null, error)); // get the minigames in the partition(optional) if (hashElements.ContainsKey("Minigame")) { minigameList = new List <MinigameTypes>(); string strAmounts = XMLUtils.GetString(hashElements["Minigame"] as IXMLNode); string[] arrayAmounts = strAmounts.Split(","[0]); for (int i = 0; i < arrayAmounts.Length; ++i) { minigameList.Add((MinigameTypes)Enum.Parse(typeof(MinigameTypes), arrayAmounts[i])); } } // get list of wellapad unlocks if (hashElements.ContainsKey("DecoTypeAllowed")) { string strStoreCategories = XMLUtils.GetString(hashElements["DecoTypeAllowed"] as IXMLNode); decoCategoriesStore = strStoreCategories.Split(","[0]); } }
public ImmutableDataFoodPreferences(string id, IXMLNode xmlNode, string errorMsg) { foodPreferences = new Dictionary <Level, string>(); List <IXMLNode> elements = XMLUtils.GetChildrenList(xmlNode); this.id = id; foreach (IXMLNode node in elements) { Hashtable attributes = XMLUtils.GetAttributes(node); string rawLevel = HashUtils.GetHashValue <string>(attributes, "Level", "", errorMsg); Level level = (Level)Enum.Parse(typeof(Level), rawLevel); string foodID = HashUtils.GetHashValue <string>(attributes, "FoodID", "", errorMsg); if (!foodPreferences.ContainsKey(level)) { foodPreferences.Add(level, foodID); } else { Debug.LogError(errorMsg + "duplicate level in food preferences"); } } }
private static void SetUpData() { hashConstants = new Hashtable(); //Load all item xml files UnityEngine.Object[] files = Resources.LoadAll("Constants", typeof(TextAsset)); foreach (TextAsset file in files) { string xmlString = file.text; //Create XMLParser instance XMLParser xmlParser = new XMLParser(xmlString); //Call the parser to build the IXMLNode objects XMLElement xmlElement = xmlParser.Parse(); string strError = "Error in file " + file.name + ": "; //Go through all child node of xmlElement (the parent of the file) for (int i = 0; i < xmlElement.Children.Count; i++) { IXMLNode childNode = xmlElement.Children[i]; Hashtable hashAttr = XMLUtils.GetAttributes(childNode); AddData(strError, hashAttr); } } }
public static void SetupData() { dictSounds = new Dictionary <string, DataSound>(); //Load all item xml files UnityEngine.Object[] files = Resources.LoadAll("Sounds", typeof(TextAsset)); foreach (TextAsset file in files) { string xmlString = file.text; //Create XMLParser instance XMLParser xmlParser = new XMLParser(xmlString); //Call the parser to build the IXMLNode objects XMLElement xmlElement = xmlParser.Parse(); //Go through all child node of xmlElement (the parent of the file) for (int i = 0; i < xmlElement.Children.Count; i++) { IXMLNode childNode = xmlElement.Children[i]; //Get id Hashtable hashAttr = XMLUtils.GetAttributes(childNode); string id = (string)hashAttr["ID"]; DataSound sound = new DataSound(id, hashAttr); // store the sound dictSounds.Add(id, sound); } } }
// Example: Form Template Method public virtual void AddSibling(String siblingTagName) { IXMLNode siblingNode = this.CreateNode(siblingTagName); this._currentNode.Add(siblingNode); this._currentNode = siblingNode; }
public ImmutableDataMerchantItem(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; type = XMLUtils.GetString(hashElements["Type"] as IXMLNode, null, error); itemId = XMLUtils.GetString(hashElements["ItemID"] as IXMLNode, null, error); }
public void Add(IXMLNode childNode) { ElementAdapter childElement = (ElementAdapter)childNode; this.GetElement.AppendChild(childElement.GetElement); DOMBuilder domBuilder = new DOMBuilder(); }
public ArrayList ParsePropertiesList(IXMLNode n) { ArrayList prop_list = new ArrayList (); foreach (IXMLNode nn in n.Children) { prop_list.Add (AttributesAsHash (nn)); } return prop_list; }
public ImmutableDataPetLevel(string id, IXMLNode xmlNode, string errorMessage) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = (Level)Enum.Parse(typeof(Level), id); levelUpCondition = XMLUtils.GetInt(hashElements["LevelUpCondition"] as IXMLNode); levelUpMessage = XMLUtils.GetString(hashElements["LevelUpMessage"] as IXMLNode); }
public ImmutableDataShooterArmy(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; name = XMLUtils.GetString(hashElements["Name"] as IXMLNode, null, error); prefabName = XMLUtils.GetString(hashElements["PrefabName"] as IXMLNode, null, error); type = XMLUtils.GetString(hashElements["Type"] as IXMLNode, null, error); }
////////////////////////////////////////// /// SetUpData() ////////////////////////////////////////// public static void SetUpData() { m_dictData = new Dictionary <string, ID_Audio>(); //Load all data xml files UnityEngine.Object[] files = Resources.LoadAll("Audio", typeof(TextAsset)); foreach (TextAsset file in files) { string xmlString = file.text; // error message string strErrorFile = "Error in file " + file.name; //Create XMLParser instance XMLParser xmlParser = new XMLParser(xmlString); //Call the parser to build the IXMLNode objects XMLElement xmlElement = xmlParser.Parse(); // this will load files that have replaced the file stored in data locally #if UNITY_STANDALONE_WIN string strFile = Application.dataPath + "/Resources/" + file.name + ".xml"; if (System.IO.File.Exists(strFile)) { Debug.Log("An override audio file was found: " + strFile); xmlString = System.IO.File.ReadAllText(strFile); } #endif //Go through all child node of xmlElement (the parent of the file) for (int i = 0; i < xmlElement.Children.Count; i++) { IXMLNode childNode = xmlElement.Children[i]; // Get list of children elements List <IXMLNode> listChildren = XMLUtils.GetChildrenList(childNode); //Get id Hashtable hashAttr = XMLUtils.GetAttributes(childNode); string strID = (string)hashAttr["ID"]; string strError = strErrorFile + "(" + strID + "): "; ID_Audio data = new ID_Audio(strID, hashAttr, listChildren, strError); // store the data if (m_dictData.ContainsKey(strID)) { Debug.LogError(strError + "Duplicate audio data!"); } else { // add data to dictionary m_dictData.Add(strID, data); } } } }
// Example: Form Template Method public virtual void AddChild(String childTagName) { IXMLNode childNode = this.CreateNode(childTagName); this._currentNode.Add(childNode); this._parentNode = this._currentNode; this._currentNode = childNode; }
/// <summary> /// Initializes a new instance of the <see cref="XMLText"/> class. /// </summary> /// <param name='text'> /// The text of the node. /// </param> /// <param name='parent'> /// This node's parent node. Should not be null for text nodes. /// </param> public XMLText(string text, IXMLNode parent) { valueString = text; parentNode = parent; if (parent != null) { parent.Children.Add(this); } }
/* Desc: This returns the children of an xml node as a hashtable. DO NOT USE THIS if there can be more than one child with the same tag name. */ public static Hashtable GetChildren(IXMLNode node){ Hashtable childrenHash = new Hashtable(); //Key: name of the xml node, Value: xml node for(int i=0; i<node.Children.Count; i++){ IXMLNode childNode = node.Children[i]; string childNodeValue = childNode.value; childrenHash[childNodeValue] = childNode; } return childrenHash; }
public ArrayList ParseCostList(IXMLNode n) { ArrayList cost_list = new ArrayList (); foreach (IXMLNode nn in n.Children) { Hashtable hh = AttributesAsHash (nn); hh ["name"] = nn.Name; cost_list.Add (hh); } return cost_list; }
public ArrayList ParseRequirementList(IXMLNode n) { ArrayList req_list = new ArrayList (); foreach (IXMLNode nn in n.Children) { Hashtable hh = AttributesAsHash (nn); hh ["name"] = nn.Name; req_list.Add (hh); } return req_list; }
public ImmutableDataMemoryTrigger(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; name = XMLUtils.GetString(hashElements["Name"] as IXMLNode, null, error); spriteName = XMLUtils.GetString(hashElements["SpriteName"] as IXMLNode, null, error); displayKey = XMLUtils.GetString(hashElements["DisplayKey"] as IXMLNode, null, error); typeParticlePrefab = XMLUtils.GetString(hashElements["Particle"] as IXMLNode, null, error); }
/* Desc: This returns the children of a xml node as a list. ONLY use this if the children all share the same tag name */ public static List<IXMLNode> GetChildrenList(IXMLNode node){ List<IXMLNode> childrenList = new List<IXMLNode>(); for(int i=0; i<node.Children.Count; i++){ IXMLNode childNode = node.Children[i]; childrenList.Add(childNode); } return childrenList; }
public ImmutableDataPartitionLocation(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; offset = StringUtils.ParseVector3(XMLUtils.GetString(hashElements["Offset"] as IXMLNode, null, error)); absolutePartition = XMLUtils.GetInt(hashElements["AbsolutePartition"] as IXMLNode, 0, error); attribute = (PartitionLocationTypes)Enum.Parse(typeof(PartitionLocationTypes), XMLUtils.GetString(hashElements["Attribute"] as IXMLNode, null, error)); }
public ArrayList ParseModifierList(IXMLNode n) { ArrayList modifier_list = new ArrayList (); foreach (IXMLNode nn in n.Children) { Hashtable hh = AttributesAsHash (nn); hh ["name"] = nn.Name; modifier_list.Add (hh); } return modifier_list; }
public ImmutableDataTrigger(string id, IXMLNode xmlNode, string errorMsg) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; name = XMLUtils.GetString(hashElements["Name"] as IXMLNode); prefabName = XMLUtils.GetString(hashElements["PrefabName"] as IXMLNode); floatyDesc = XMLUtils.GetString(hashElements["FloatyDesc"] as IXMLNode); scene = XMLUtils.GetString(hashElements["Scene"] as IXMLNode); }
public static void SetupData() { hashData = new Hashtable(); //Load all data xml files UnityEngine.Object[] files = Resources.LoadAll("Ninja/Modes", typeof(TextAsset)); foreach (TextAsset file in files) { string xmlString = file.text; // error message string strErrorFile = "Error in file " + file.name; //Create XMLParser instance XMLParser xmlParser = new XMLParser(xmlString); //Call the parser to build the IXMLNode objects XMLElement xmlElement = xmlParser.Parse(); // we store the data per mode of the ninja game. the name of the file is the mode. NinjaModes eMode = (NinjaModes)System.Enum.Parse(typeof(NinjaModes), file.name); hashData[eMode] = new Hashtable(); Hashtable hashMode = (Hashtable)hashData[eMode]; //Go through all child node of xmlElement (the parent of the file) for (int i = 0; i < xmlElement.Children.Count; i++) { IXMLNode childNode = xmlElement.Children[i]; // Get id Hashtable hashAttr = XMLUtils.GetAttributes(childNode); string id = (string)hashAttr["ID"]; string strError = strErrorFile + "(" + id + "): "; NinjaData data = new NinjaData(id, hashAttr, childNode, strError); // we want to stuff the data in each of its scoring categories List <NinjaScoring> listScoring = data.GetScoringCategories(); for (int j = 0; j < listScoring.Count; ++j) { NinjaScoring eScoring = listScoring[j]; // if the mode doesn't contain this scoring key yet, add it if (!hashMode.ContainsKey(eScoring)) { hashMode[eScoring] = new List <NinjaData>(); } // add the data to the list of data for this mode/scoring key List <NinjaData> listData = (List <NinjaData>)hashMode[eScoring]; listData.Add(data); } } } }
/* Desc: This returns all the attributes of a node as a hashtable */ public static Hashtable GetAttributes(IXMLNode node){ Hashtable attributesHash = new Hashtable(); //Key: attribute name, Value: attribute value for(int i=0; i<node.Attributes.Count; i++){ XMLAttribute attr = node.Attributes[i]; string attrKey = attr.name; string attrValue = attr.value; attributesHash[attrKey] = attrValue; } return attributesHash; }
/// <summary> /// Initializes a new instance of the <see cref="XMLElement"/> class. /// </summary> /// <param name='name'> /// Tage Name of this XMLElement. /// </param> /// <param name='parent'> /// The Parent node. /// </param> /// <param name='children'> /// List of child nodes /// </param> /// <param name='attributes'> /// List of attributes. /// </param> public XMLElement(string name, IXMLNode parent, List <IXMLNode> children, List <XMLAttribute> attributes) { valueString = name; parentNode = parent; childList = children; attributeList = attributes; if (parent != null) { parent.Children.Add(this); } }
public ImmutableDataSkill(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.id = id; name = XMLUtils.GetString(hashElements["Name"] as IXMLNode, null, error); textureName = XMLUtils.GetString(hashElements["TextureName"] as IXMLNode, null, error); strFlameResource = XMLUtils.GetString(hashElements["ParticleResource"] as IXMLNode, null, error); description = XMLUtils.GetString(hashElements["Description"] as IXMLNode, null, error); unlockLevel = XMLUtils.GetInt(hashElements["UnlockLevel"] as IXMLNode, 0, error); }
/// <summary> /// Initializes a new instance of the <see cref="XMLElement"/> class. /// </summary> /// <param name='name'> /// Tage Name of this XMLElement. /// </param> /// <param name='parent'> /// The Parent node. /// </param> public XMLElement(string name, IXMLNode parent) { valueString = name; parentNode = parent; childList = new List <IXMLNode> (); attributeList = new List <XMLAttribute> (); if (parent != null) { parent.Children.Add(this); } }
// for each child node that has a matching attribute, adds the attribute // to the list then returns the list public ArrayList ParseChildrenForAttribute(IXMLNode n, string attribute) { ArrayList list = new ArrayList (); foreach (IXMLNode nn in n.Children) { string attributeValue = nn.GetAttribute (attribute); if (attributeValue != null) { list.Add (attributeValue); } } return list; }
/// <summary> /// This returns the children of an xml node as a hashtable. /// DO NOT USE THIS if there can be more than one child with the same tag name. /// </summary> /// <returns>The children.</returns> /// <param name="node">Node.</param> public static Hashtable GetChildren(IXMLNode node) { Hashtable childrenHash = new Hashtable(); //Key: name of the xml node, Value: xml node for (int i = 0; i < node.Children.Count; i++) { IXMLNode childNode = node.Children[i]; string childNodeValue = childNode.value; childrenHash[childNodeValue] = childNode; } return(childrenHash); }
public ImmutableDataMonster(string id, IXMLNode xmlNode, string errorMsg) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); monsterID = id; // get monster hp monsterHP = XMLUtils.GetInt(hashElements["Health"] as IXMLNode, 100, errorMsg); // get prefab that this monster spawns resourceKey = XMLUtils.GetString(hashElements["PrefabName"] as IXMLNode, "SmokeMonster", errorMsg); }
/// <summary> /// This returns the children of a xml node as a list. ONLY use this if /// the children all share the same tag name /// </summary> /// <returns>The children list.</returns> /// <param name="node">Node.</param> public static List <IXMLNode> GetChildrenList(IXMLNode node) { List <IXMLNode> childrenList = new List <IXMLNode>(); for (int i = 0; i < node.Children.Count; i++) { IXMLNode childNode = node.Children[i]; childrenList.Add(childNode); } return(childrenList); }
public ImmutableDataWave(string id, IXMLNode xmlNode, string error) { Hashtable hashElements = XMLUtils.GetChildren(xmlNode); this.waveID = id; totalEnemies = XMLUtils.GetInt(hashElements["NumOfEnemies"] as IXMLNode, 0, error); begEnemiesCount = XMLUtils.GetInt(hashElements["BasicEnemies"] as IXMLNode, 0, error); mediumEnemiesCount = XMLUtils.GetInt(hashElements["MediumEnemies"] as IXMLNode, 0, error); hardEnemiesCount = XMLUtils.GetInt(hashElements["HardEnemies"] as IXMLNode, 0, error); powerUpCount = XMLUtils.GetInt(hashElements["PowerUps"] as IXMLNode, 0, error); bossRound = XMLUtils.GetBool(hashElements["Bossround"] as IXMLNode); }
protected override void XMLNodeHandler(string id, IXMLNode xmlNode, Hashtable hashData, string errorMessage) { ImmutableDataMonster data = new ImmutableDataMonster(id, xmlNode, errorMessage); if (hashData.ContainsKey(id)) { Debug.LogError(errorMessage + "Duplicate keys!"); } else { hashData.Add(id, data); } }
public ImmutableDataPetAnimationSound(string id, IXMLNode xmlNode, string errorMsg) { soundClipNames = new List <string>(); List <IXMLNode> elements = XMLUtils.GetChildrenList(xmlNode); this.id = id; foreach (IXMLNode node in elements) { string clipName = XMLUtils.GetString(node, "", errorMsg); soundClipNames.Add(clipName); } }
public static int GetInt(IXMLNode node, int defaultValue, string strError = null){ int retVal = defaultValue; if(node != null){ if(node.Children.Count == 1) retVal = Convert.ToInt32(node.Children[0].value); else Debug.LogError("Incoming element has more than one child...can't get value: " + node + "(" + node.Children.Count + ")"); } else if ( strError != null ) Debug.LogError(strError + "Required data is missing."); return retVal; }
/// <summary> /// This returns all the attriutes of a node as a hashtable /// </summary> /// <returns>The attributes.</returns> /// <param name="node">Node.</param> public static Hashtable GetAttributes(IXMLNode node) { Hashtable attributesHash = new Hashtable(); //Key: attribute name, Value: attribute value for (int i = 0; i < node.Attributes.Count; i++) { XMLAttribute attr = node.Attributes[i]; string attrKey = attr.name; string attrValue = attr.value; attributesHash[attrKey] = attrValue; } return(attributesHash); }
public static string GetString(IXMLNode node, string defaultstring, string strError = null){ string retVal = defaultstring; if(node != null){ if(node.Children.Count != 0) retVal = node.Children[0].value; else Debug.LogError("Incoming element has more than one child...can't get value: " + node + "(" + node.Children.Count + ")"); } else if ( strError != null ) Debug.LogError(strError + "Required data is missing."); return retVal; }
protected void OnUpdate(IXMLNode update) { //Since you can get change events from login calls, when the Properties object is not yet setup we need to be careful here: if (! HasDataFromServer) return; //var d = event['data'] as Hashtable; var v = GetProperty (update.GetAttribute ("ikey")) as Hashtable; if (v != null) { v ["value"] = update.GetAttribute ("value"); } }
private void AddData( string i_strError, IXMLNode i_element ) { // i_element is the root element, English // each child of this element is an individual string key for ( int i = 0; i < i_element.Children.Count; ++i ) { IXMLNode entry = i_element.Children[i]; Hashtable hashAttributes = XMLUtils.GetAttributes( entry ); string strID = (string)hashAttributes["ID"]; string strValue = XMLUtils.GetString( entry ); if ( m_dictStrings.ContainsKey(strID) ) Debug.Log(i_strError + "Duplicate string ID: " + strID); else m_dictStrings[strID] = strValue; } }
public string GetKey(IXMLNode n) { return n.GetAttribute ("ikey"); }
public Hashtable BuildHashtable(IXMLNode n) { Hashtable retval = new Hashtable (); retval ["ikey"] = n.GetAttribute ("ikey"); foreach (IXMLNode nn in n.Children) { switch (nn.Name) { case "location": break; case "mastery_level": break; case "rewards": retval ["rewards"] = CrmParser_.ParseModifierList (nn); break; case "costs": retval ["costs"] = CrmParser_.ParseCostList (nn); break; case "requires": retval ["requires"] = CrmParser_.ParseRequirementList (nn); break; case "tags": retval ["tags"] = CrmParser_.ParseChildrenForAttribute (nn, "value"); break; case "properties": retval ["properties"] = CrmParser_.ParsePropertiesList (nn); break; default: retval [nn.Name] = nn.Text; break; } } return retval; }
public static void OnRoarServerTaskComplete( IXMLNode info ) { if(roarServerTaskCompleteEvent!=null) roarServerTaskCompleteEvent(info); }
public Hashtable BuildHashtable(IXMLNode n) { Hashtable retval = new Hashtable (); foreach (KeyValuePair<string,string> kv in n.Attributes) { //We move the ikey to shop_ikey if (kv.Key == "ikey") { retval ["shop_ikey"] = kv.Value; } else { retval [kv.Key] = Native.Extract (kv.Value); } } foreach (IXMLNode nn in n.Children) { switch (nn.Name) { case "costs": retval ["costs"] = CrmParser_.ParseCostList (nn); break; case "modifiers": //We require and expect that there be only one modifier and that modifier is a grant_item //were we to support the more general case we'd do this: // retval["modifiers"] = CrmParser_.ParseModifierList( nn ); IXMLNode grantItemNode = nn.GetFirstChild ("grant_item"); if (grantItemNode != null) { retval ["ikey"] = grantItemNode.GetAttribute ("ikey"); } break; case "tags": retval ["tags"] = CrmParser_.ParseChildrenForAttribute (nn, "value"); break; case "properties": retval ["properties"] = CrmParser_.ParsePropertiesList (nn); break; default: retval [nn.Name] = nn.Text; break; } } return retval; }
/// <summary> /// Initializes a new instance of the <see cref="XMLText"/> class. /// </summary> /// <param name='text'> /// The text of the node. /// </param> /// <param name='parent'> /// This node's parent node. Should not be null for text nodes. /// </param> public XMLText (string text, IXMLNode parent) { valueString = text; parentNode = parent; if (parent != null) { parent.Children.Add (this); } }
/** * Fire the correct event for a server chunk. * * @param key the event name. * @param info the event info. **/ public static void OnServerEvent( string key, IXMLNode info ) { switch(key) { case "update": OnRoarServerUpdate(info); break; case "item_use": OnRoarServerItemUse(info); break; case "item_lose": OnRoarServerItemLose(info); break; case "inventory_changed": OnRoarServerInventoryChanged(info); break; case "regen": OnRoarServerRegen(info); break; case "item_add": OnRoarServerItemAdd(info); break; case "task_complete": OnRoarServerTaskComplete(info); break; default: Debug.Log("Server event "+key+" not yet implemented"); break; } }
protected Hashtable AttributesAsHash(IXMLNode n) { Hashtable h = new Hashtable (); foreach (KeyValuePair<string,string> kv in n.Attributes) { h [kv.Key] = Native.Extract (kv.Value); } return h; }
public Hashtable BuildHashtable(IXMLNode n) { Hashtable retval = new Hashtable (); foreach (KeyValuePair<string,string> kv in n.Attributes) { retval [kv.Key] = Native.Extract (kv.Value); } return retval; }
public virtual string GetKey(IXMLNode n) { return n.GetAttribute ("id"); }
public Hashtable BuildHashtable(IXMLNode n) { Hashtable retval = new Hashtable (); foreach (KeyValuePair<string,string> kv in n.Attributes) { retval [kv.Key] = Native.Extract (kv.Value); } foreach (IXMLNode nn in n.Children) { switch (nn.Name) { case "price": retval ["price"] = CrmParser_.ParseModifierList (nn); break; case "tags": retval ["tags"] = CrmParser_.ParseChildrenForAttribute (nn, "value"); break; case "properties": retval ["properties"] = CrmParser_.ParsePropertiesList (nn); break; default: retval [nn.Name] = nn.Text; break; } } return retval; }
public Hashtable BuildHashtable(IXMLNode n) { Hashtable retval = new Hashtable (); foreach (KeyValuePair<string,string> kv in n.Attributes) { retval [kv.Key] = Native.Extract (kv.Value); } foreach (IXMLNode nn in n.Children) { switch (nn.Name) { case "costs": retval ["costs"] = CrmParser_.ParseCostList (nn); break; case "requirements": retval ["requirements"] = CrmParser_.ParseRequirementList (nn); break; default: retval [nn.Name] = nn.Text; break; } } return retval; }
public string GetKey(IXMLNode n) { return n.GetAttribute ("product_identifier"); }
public string GetKey(IXMLNode n) { string key = n.GetAttribute ("ikey"); if (key != null) return key; return n.GetAttribute ("name"); }
/// <summary> /// Initializes a new instance of the <see cref="XMLElement"/> class. /// </summary> /// <param name='name'> /// Tage Name of this XMLElement. /// </param> /// <param name='parent'> /// The Parent node. /// </param> public XMLElement (string name, IXMLNode parent) { valueString = name; parentNode = parent; childList = new List<IXMLNode> (); attributeList = new List<XMLAttribute> (); if (parent != null) { parent.Children.Add (this); } }
public <%= response %> Build(IXMLNode n) {
public static void OnRoarServerUpdate( IXMLNode info ) { if(roarServerUpdateEvent!=null) roarServerUpdateEvent(info); }
public Hashtable BuildHashtable(IXMLNode n) { Hashtable retval = new Hashtable (); Hashtable properties = new Hashtable (); ArrayList entries = new ArrayList(); foreach (KeyValuePair<string,string> kv in n.Attributes) { //Debug.Log (string.Format ("BuildHashtable: {0} => {1}", kv.Key, kv.Value)); properties [kv.Key] = Native.Extract (kv.Value); } foreach (IXMLNode child in n.Children) { Hashtable entry = new Hashtable(); foreach (KeyValuePair<string,string> kv in child.Attributes) { //Debug.Log (string.Format ("BuildHashtable: {0} => {1}", kv.Key, kv.Value)); entry[kv.Key] = Native.Extract(kv.Value); // any custom data? need the player_name if it's there foreach (IXMLNode subChild in child.Children) { if (subChild.Name == "custom") { foreach (IXMLNode propertyNode in subChild.Children) { string propertyKey = string.Empty, propertyValue = string.Empty; foreach (KeyValuePair<string,string> kvp in propertyNode.Attributes) { if (kvp.Key == "ikey") propertyKey = kvp.Value; else if (kvp.Key == "value") propertyValue = kvp.Value; } if (propertyKey.Length > 0) entry[propertyKey] = propertyValue; } } } } entries.Add(entry); } retval.Add("properties", properties); retval.Add("entries", entries); return retval; }
/// <summary> /// Initializes a new instance of the <see cref="XMLElement"/> class. /// </summary> /// <param name='name'> /// Tage Name of this XMLElement. /// </param> /// <param name='parent'> /// The Parent node. /// </param> /// <param name='children'> /// List of child nodes /// </param> /// <param name='attributes'> /// List of attributes. /// </param> public XMLElement (string name, IXMLNode parent, List<IXMLNode> children, List<XMLAttribute> attributes) { valueString = name; parentNode = parent; childList = children; attributeList = attributes; if (parent != null) { parent.Children.Add (this); } }