private JToken GetJToken(IPlistXmlItem item) { if (item is PListXmlItemUid) { int uid = (item as PListXmlItemUid).Value; return(GetJToken(this.Items[uid])); } else if (item is PListXmlItemDict) { return(GetJObject((item as PListXmlItemDict))); } else if (item is PListXmlItemInteger) { return((item as PListXmlItemInteger).Value); } else if (item is PListXmlItemString) { return((item as PListXmlItemString).Value); } else if (item is PListXmlItemArray) { return(GetJArray(item as PListXmlItemArray)); } else if (item is PListXmlItemFalse) { return("false"); } else if (item is PListXmlItemTrue) { return("true"); } return(string.Empty); }
public JToken LoadXml(XElement xmlDoc) { var topNode = xmlDoc.Element("dict").Element("array"); this.Items = new List <IPlistXmlItem>(); IPlistXmlItem tempItem = null; foreach (var node in topNode.Elements()) { tempItem = LoadXmlNode(node); if (null != tempItem) { tempItem.Uid = this.Items.Count; this.Items.Add(tempItem); } else { tempItem = new PListXmlItemString(); tempItem.Uid = this.Items.Count; this.Items.Add(tempItem); } } PListXmlItemDict root = this.Items[1] as PListXmlItemDict; return(GetJObject(root)); }
public void Load(XElement node) { Value = new List <IPlistXmlItem>(); IPlistXmlItem tempItem = null; foreach (var childNode in node.Elements()) { tempItem = PListXmlReader.LoadXmlNode(childNode); if (null != tempItem) { Value.Add(tempItem); } } }
public static IPlistXmlItem LoadXmlNode(XElement node) { IPlistXmlItem tempItem = null; switch (node.Name.LocalName) { case "string": case "ustring": tempItem = new PListXmlItemString(); break; case "dict": tempItem = new PListXmlItemDict(); break; case "integer": tempItem = new PListXmlItemInteger(); break; case "array": tempItem = new PListXmlItemArray(); break; case "uid": tempItem = new PListXmlItemUid(); break; case "false": tempItem = new PListXmlItemFalse(); break; case "true": tempItem = new PListXmlItemTrue(); break; default: tempItem = null; break; } if (null != tempItem) { tempItem.Load(node); } return(tempItem); }
public void Load(XElement node) { Value = new Dictionary <string, IPlistXmlItem>(); string key = string.Empty; IPlistXmlItem tempItem = null; var nodes = node.Elements().ToList(); int count = nodes.Count / 2; for (int pos = 0; pos < count; pos++) { key = nodes[2 * pos].Value; tempItem = PListXmlReader.LoadXmlNode(nodes[2 * pos + 1]); if (null != tempItem) { Value.Add(key, tempItem); } } }