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()
        {
            JsonCNode result = new JsonCNode();

            result.Name           = this.Name;
            result.IsArray        = this.IsArray;
            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 ParseJson(JsonCNode root, JObject jObject, int rank, bool isArray = false)
        {
            JToken[] jTArray = jObject.Children().ToArray();
            rank++;
            foreach (JToken jt in jTArray)
            {
                JProperty jp = jt.ToObject <JProperty>();
                if (jp.Value.Type == JTokenType.Array)
                {
                    isArray = true;
                }
                else
                {
                    isArray = false;
                }
                JsonCNode tNode = (JsonCNode)root.ChildrenNode.Where(s => s.Name == jp.Name).FirstOrDefault();
                if (tNode == null)
                {
                    JsonCNode jn = new JsonCNode();
                    jn.IsArray = isArray;
                    jn.Name    = jp.Name;
                    jn.Rank    = rank;
                    jn.Parent  = root;
                    jn.Count   = startCount;
                    root.ChildrenNode.Add(jn);
                    tNode = jn;
                }
                else
                {
                    tNode.Count++;
                }

                if (jp.Value is JObject)
                {
                    ParseJson(tNode, jp.Value as JObject, rank);
                }
                else if (jp.Value is JArray)
                {
                    JArray ja = jp.Value as JArray;
                    ParseArray(tNode, ja, rank);
                }
            }
        }
Esempio n. 4
0
 private void ParseArray(JsonCNode root, JArray array, int rank)
 {
     if (array.Count > 0)
     {
         foreach (JToken fa in array)
         {
             if (fa is JObject)
             {
                 ParseJson(root, fa as JObject, rank);
             }
             else if (fa is JArray)
             {
                 ParseArray(root, fa as JArray, rank);
             }
         }
     }
     else
     {
         Debug.Assert(true);
     }
 }