public static ItemArchetype CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser) { DomainObjects.ItemArchetype retval = new DomainObjects.ItemArchetype(); retval.id = n.GetAttributeOrDefault("id", null); retval.ikey = n.GetAttributeOrDefault("ikey", null); retval.type = n.GetAttributeOrDefault("type", null); retval.label = n.GetAttributeOrDefault("label", null); retval.description = n.GetAttributeOrDefault("description", null); if (n.HasAttribute("consumable")) { retval.consumable = n.GetAttribute("consumable").ToLower() == "true"; } if (n.HasAttribute("sellable")) { retval.sellable = n.GetAttribute("sellable").ToLower() == "true"; } retval.stats = ixcrm_parser.ParseItemStatList(n.SelectSingleNode("./stats") as System.Xml.XmlElement); retval.price = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./price") as System.Xml.XmlElement); retval.tags = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement); System.Xml.XmlNodeList property_nodes = n.SelectNodes("./properties/property"); foreach (System.Xml.XmlElement property_node in property_nodes) { Roar.DomainObjects.ItemArchetypeProperty property = new Roar.DomainObjects.ItemArchetypeProperty(); property.ikey = property_node.GetAttribute("ikey"); property.value = property_node.GetAttribute("value"); retval.properties.Add(property); } return(retval); }
public static GoogleFriend CreateFromXml(System.Xml.XmlElement n) { GoogleFriend retval = new GoogleFriend(); retval.id = n.GetAttributeOrDefault("id", null); retval.name = n.GetAttributeOrDefault("name", null); retval.gplus_id = n.GetAttributeOrDefault("gplus_id", null); retval.gplus_name = n.GetAttributeOrDefault("gplus_name", null); return(retval); }
public void ParseXml(System.Xml.XmlElement nn) { ikey = nn.GetAttributeOrDefault("ikey", null); name = nn.GetAttribute("name"); if (ikey == null) { ikey = name; } label = nn.GetAttribute("label"); value = nn.GetAttribute("value"); type = nn.GetAttribute("type"); min = nn.GetAttribute("min"); max = nn.GetAttribute("max"); regen_amount = nn.GetAttribute("regen_amount"); regen_every = nn.GetAttribute("regen_every"); next_regen = nn.GetAttribute("next_regen"); level_start = nn.GetAttribute("level_start"); next_level = nn.GetAttribute("next_level"); }
public ShopEntry Build(System.Xml.XmlElement n) { ShopEntry retval = new ShopEntry(); retval.ikey = n.GetAttributeOrDefault("ikey", null); retval.label = n.GetAttribute("label"); retval.description = n.GetAttribute("description"); foreach (System.Xml.XmlAttribute a in n.Attributes) { if (a.Name == "ikey") { continue; } if (a.Name == "label") { continue; } if (a.Name == "description") { continue; } throw new UnexpectedXMLElementException("unexpected attribute, \"" + a.Name + "\", on ShopEntry"); } if (retval.ikey == null) { throw new MissingXMLElementException("missing attribute, \"ikey\", on ShopEntry"); } retval.costs = new List <Cost>(); retval.modifiers = new List <Modifier>(); foreach (System.Xml.XmlNode nn_n in n) { if (nn_n.NodeType != System.Xml.XmlNodeType.Element) { continue; } System.Xml.XmlElement nn = nn_n as System.Xml.XmlElement; switch (nn.Name) { case "costs": retval.costs = CrmParser_.ParseCostList(nn); break; case "modifiers": retval.modifiers = CrmParser_.ParseModifierList(nn); break; case "requirements": retval.requirements = CrmParser_.ParseRequirementList(nn); break; case "tags": retval.tags = CrmParser_.ParseTagList(nn); break; case "properties": // retval.properties = CrmParser_.ParsePropertiesList (nn); break; default: throw new UnexpectedXMLElementException("unexpected element, \"" + nn.Name + "\", in ShopEntry"); //retval [nn.Name] = nn.Text; } } return(retval); }
public DomainObjects.Requirement ParseARequirement(System.Xml.XmlElement n) { DomainObjects.Requirement retval; switch (n.Name) { case "friends_requirement": DomainObjects.Requirements.Friends friends = new DomainObjects.Requirements.Friends(); if (!System.Int32.TryParse(n.GetAttribute("required"), out friends.required)) { throw new InvalidXMLElementException("Unable to parse required to integer"); } retval = friends; break; case "and": DomainObjects.Requirements.And and = new DomainObjects.Requirements.And(); retval = and; break; case "true_requirement": retval = new DomainObjects.Requirements.True(); break; case "false_requirement": retval = new DomainObjects.Requirements.False(); break; case "level_requirement": DomainObjects.Requirements.Level level_req = new DomainObjects.Requirements.Level(); if (!System.Int32.TryParse(n.GetAttribute("level"), out level_req.level)) { throw new InvalidXMLElementException("Unable to parse level restriction to integer"); } ; retval = level_req; break; case "item_requirement": DomainObjects.Requirements.Item item_req = new DomainObjects.Requirements.Item(); item_req.ikey = n.GetAttribute("ikey"); if (!System.Int32.TryParse(n.GetAttribute("number_required"), out item_req.number_required)) { throw new InvalidXMLElementException("Unable to parse item count to integer"); } retval = item_req; break; case "stat_requirement": DomainObjects.Requirements.Stat stat_req = new DomainObjects.Requirements.Stat(); stat_req.ikey = n.GetAttribute("ikey"); stat_req.type = n.GetAttribute("type"); if (!System.Int32.TryParse(n.GetAttribute("value"), out stat_req.value)) { throw new InvalidXMLElementException("Unable to parse value in stat requirement"); } retval = stat_req; break; case "multiple": DomainObjects.Requirements.Multiple multiple_req = new DomainObjects.Requirements.Multiple(); multiple_req.requirements = ParseRequirementList(n); retval = multiple_req; break; default: throw new InvalidXMLElementException("Invalid requirement type : " + n.Name); } retval.ok = (n.GetAttribute("ok") == "true"); retval.reason = n.GetAttributeOrDefault("reason", null); return(retval); }