示例#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
 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);
                 var propertyList = new List<Tuple<string, string>>();
                 propertyList.Add(Tuple.Create(e.Attribute("key").Value, e.Attribute("value").Value));
                 foreach (var p in e.Elements("property"))
                 {
                     propertyList.Add(Tuple.Create(p.Attribute("key").Value, p.Attribute("value").Value));
                 }
                 pick.Properties = propertyList;
                 ret.Items.Add(pick);
                 break;
         }
     }
     return ret;
 }