Esempio n. 1
0
 private void ParseDirectoryNode(DirectoryCNode rNode, Parser psr, bool parseFlag)
 {
     if (rNode != null)
     {
         List <string> filePathList;
         CNode         dNode;
         if (parseFlag)
         {
             filePathList = rNode.xmlPathList;
             dNode        = new XmlCNode();
         }
         else
         {
             filePathList = rNode.jsonPathList;
             dNode        = new JsonCNode();
         }
         ParseFile(dNode, psr, filePathList);
         if (dNode.ChildrenNode.Count > 0)
         {
             rNode.CurrentNodeList.Add(dNode);
         }
         foreach (CNode node in rNode.ChildrenNode)
         {
             ParseDirectoryNode(node as DirectoryCNode, psr, parseFlag);
         }
     }
 }
Esempio n. 2
0
        public override object Clone()
        {
            XmlCNode result = new XmlCNode();

            result.Name           = this.Name;
            result.HasChildren    = this.HasChildren;
            result.IsEditNodeName = this.IsEditNodeName;
            result.Rank           = this.Rank;
            result.OperationType  = this.OperationType;
            result.AddContent     = this.AddContent;
            result.AddName        = this.AddName;
            result.Count          = this.Count;
            if (this.DeleteConditionCollection == null)
            {
                result.DeleteConditionCollection = null;
            }
            else
            {
                List <DeleteCondition> tempDCList = new List <DeleteCondition>();
                foreach (DeleteCondition dc in this.DeleteConditionCollection)
                {
                    tempDCList.Add(dc.Clone() as DeleteCondition);
                }
                result.DeleteConditionCollection = new ObservableCollection <DeleteCondition>(tempDCList);
            }
            result.EditName  = this.EditName;
            result.EditValue = this.EditValue;
            result.Parent    = this.Parent;
            if (this.ChildrenNode == null)
            {
                result.ChildrenNode = null;
            }
            else
            {
                List <CNode> tempNodeList = new List <CNode>();
                foreach (CNode node in this.ChildrenNode)
                {
                    tempNodeList.Add(node.Clone() as CNode);
                }
                result.ChildrenNode = new ObservableCollection <CNode>(tempNodeList);
            }
            return(result as object);
        }
Esempio n. 3
0
        private void ParseXml(XmlNode xDoc, CNode root, int rank)
        {
            XmlNodeList Nodechildren = xDoc.ChildNodes;

            rank++;
            foreach (XmlNode xn in Nodechildren)
            {
                if (xn is XmlElement)
                {
                    XmlCNode thisNode = (XmlCNode)root.ChildrenNode.Where(cn => cn.Name == xn.Name).FirstOrDefault();
                    if (thisNode == null)
                    {
                        XmlCNode newNode = new XmlCNode();
                        newNode.Name   = xn.Name;
                        newNode.Rank   = rank;
                        newNode.Parent = root;
                        newNode.Count  = startCount;
                        root.ChildrenNode.Add(newNode);
                        thisNode = newNode;
                    }
                    else
                    {
                        thisNode.Count++;
                    }
                    foreach (XmlAttribute xa in xn.Attributes)
                    {
                        if (thisNode.Attributes.Keys.Contains(xa.Name))
                        {
                            thisNode.Attributes[xa.Name]++;
                        }
                        else
                        {
                            thisNode.Attributes.Add(xa.Name, startCount);
                        }
                    }
                    ParseXml(xn, thisNode, rank);
                }
            }
        }