Beispiel #1
0
            public static Mailable CreateFromXml(System.Xml.XmlElement n, IXCRMParser ixcrm_parser)
            {
                Mailable retval = new Mailable();

                retval.id           = n.GetAttribute("id");
                retval.type         = n.GetAttribute("type");
                retval.label        = n.GetAttribute("label");
                retval.requirements = ixcrm_parser.ParseRequirementList(n.SelectSingleNode("./requirements") as System.Xml.XmlElement);
                retval.costs        = ixcrm_parser.ParseCostList(n.SelectSingleNode("./costs") as System.Xml.XmlElement);
                retval.on_accept    = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./on_accept") as System.Xml.XmlElement);
                retval.on_give      = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./on_give") as System.Xml.XmlElement);
                retval.tags         = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement);
                return(retval);
            }
Beispiel #2
0
            public static ShopEntry CreateFromXml(System.Xml.XmlElement n, IXCRMParser xcrm_parser)
            {
                ShopEntry retval = new ShopEntry();

                retval.ikey        = n.GetAttribute("ikey");
                retval.label       = n.GetAttribute("label");
                retval.description = n.GetAttribute("description");


                System.Xml.XmlElement costs_node = n.SelectSingleNode("./costs") as System.Xml.XmlElement;
                if (costs_node != null)
                {
                    retval.costs = xcrm_parser.ParseCostList(costs_node);
                }
                // else branches not necessary as costs, modifiers and requirements are INITIALISED by definition

                System.Xml.XmlElement modifiers_node = n.SelectSingleNode("./modifiers") as System.Xml.XmlElement;
                if (modifiers_node != null)
                {
                    retval.modifiers = xcrm_parser.ParseModifierList(modifiers_node);
                }

                System.Xml.XmlElement requirements_node = n.SelectSingleNode("./requirements") as System.Xml.XmlElement;
                if (requirements_node != null)
                {
                    retval.requirements = xcrm_parser.ParseRequirementList(requirements_node);
                }

                System.Xml.XmlNodeList tag_nodes = n.SelectNodes("./tags/tag");
                foreach (System.Xml.XmlElement tag_node in tag_nodes)
                {
                    retval.tags.Add(tag_node.GetAttribute("value"));
                }

                return(retval);
            }
Beispiel #3
0
        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);
        }