Exemple #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);
            }
Exemple #2
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);
        }