public List <TagItemModel> CreateDataTree(TagItem parent = null) { if (parent == null) { parent = TagRoot; } var tempList = new List <TagItemModel>(); if (!parent.HaveChilds()) { return(tempList); } tempList.AddRange(parent.GetChilds().Select(node => node.Transform())); return(tempList); }
private void CreateStructure(TagItem root, XmlNode parent) { var tag = _storage.CreateElement("tag"); var nameAttr = _storage.CreateAttribute("name"); var pathAttr = _storage.CreateElement("FullPath"); var levelAttr = _storage.CreateElement("Level"); var valueTypeAttr = _storage.CreateElement("ValueType"); var valueAttr = _storage.CreateElement("Value"); var nameText = _storage.CreateTextNode(root.GetName()); var pathText = _storage.CreateTextNode(root.GetFullPath()); var levelText = _storage.CreateTextNode(root.GetLevel().ToString()); var valueTypeText = _storage.CreateTextNode(TagItem.GetTypeOfValue(root)); var valueText = _storage.CreateTextNode(root.GetValue().ToString()); nameAttr.AppendChild(nameText); pathAttr.AppendChild(pathText); levelAttr.AppendChild(levelText); valueAttr.AppendChild(valueText); valueTypeAttr.AppendChild(valueTypeText); tag.Attributes.Append(nameAttr); tag.AppendChild(pathAttr); tag.AppendChild(levelAttr); tag.AppendChild(valueAttr); tag.AppendChild(valueTypeAttr); if (root.HaveChilds()) { var childElement = _storage.CreateElement("Childs"); foreach (var child in root.GetChilds()) { CreateStructure(child, childElement); } tag.AppendChild(childElement); } if (parent != null) { parent.AppendChild(tag); } else { _storage.AppendChild(tag); } }
public TagItemModel(TagItem tag) { TagName = tag.GetName(); Header = TagName; FullPath = tag.GetFullPath(); Level = tag.GetLevel(); TagParent = tag.GetParent(); TagType = tag.GetTypeOfValue(); switch (TagType) { case "Bool": Value = tag.GetValue().ToString(); Tag = "Images/Bool.png"; break; case "Int": Value = tag.GetValue().ToString(); Tag = "Images/Integer.png"; break; case "Double": Value = tag.GetValue().ToString(); Tag = "Images/Double.png"; break; case "None": Value = ""; Tag = "Images/None.png"; break; } if (!tag.HaveChilds()) { return; } foreach (var item in tag.GetChilds()) { Items.Add(item.Transform()); } }