Ejemplo n.º 1
0
            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);
            }
Ejemplo n.º 2
0
            public static InventoryItem CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser)
            {
                DomainObjects.InventoryItem retval = new DomainObjects.InventoryItem();
                retval.id          = n.GetAttribute("id");
                retval.ikey        = n.GetAttribute("ikey");
                retval.type        = n.GetAttribute("type");
                retval.label       = n.GetAttribute("label");
                retval.description = n.GetAttribute("description");

                if (n.HasAttribute("count") && !System.Int32.TryParse(n.GetAttribute("count"), out retval.count))
                {
                    throw new InvalidXMLElementException("Unable to parse count to integer");
                }
                if (n.HasAttribute("consumable"))
                {
                    retval.consumable = n.GetAttribute("consumable").ToLower() == "true";
                }
                if (n.HasAttribute("sellable"))
                {
                    retval.sellable = n.GetAttribute("sellable").ToLower() == "true";
                }
                if (n.HasAttribute("equipped"))
                {
                    retval.equipped = n.GetAttribute("equipped").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);
            }