示例#1
0
        internal PackDefinition DeserializePack(IEnumerable <XElement> element)
        {
            var ret = new PackDefinition();

            foreach (var e in element)
            {
                switch (e.Name.LocalName)
                {
                case "options":
                    ret.Items.Add(this.DeserializeOptions(e));
                    break;

                case "pick":
                    var pick    = new Pick();
                    var qtyAttr = e.Attributes().FirstOrDefault(x => x.Name.LocalName == "qty");
                    if (qtyAttr != null)
                    {
                        pick.Quantity = qtyAttr.Value == "unlimited" ? -1 : int.Parse(qtyAttr.Value);
                    }
                    pick.Key   = e.Attribute("key").Value;
                    pick.Value = e.Attribute("value").Value;
                    ret.Items.Add(pick);
                    break;
                }
            }
            return(ret);
        }
示例#2
0
 public Pack(Set set, string xml)
 {
     Set = set;
     using (var stringReader = new StringReader(xml))
         using (XmlReader reader = XmlReader.Create(stringReader))
         {
             reader.Read();
             string guid = reader.GetAttribute("id");
             if (guid != null)
             {
                 Id = new Guid(guid);
             }
             Name = reader.GetAttribute("name");
             reader.ReadStartElement("pack");
             Definition = new PackDefinition(reader);
             reader.ReadEndElement(); // </pack>
         }
 }