Beispiel #1
0
        public void LoadArrayNode(ArrayNode node, NewNode currentNode, int counter)
        {
            var key = node.Index;

            if (currentNode == null)
            {
                currentNode = new NewNode();
                FlattenedNodes.Add(currentNode);
            }
            currentNode.AddKeyNode(node, "[" + key + "]");

            foreach (var nodeValue in node.Values)
            {
                if (currentNode.HasValueNode)
                {
                    var nodes        = currentNode.GetNodes();
                    var currentNode2 = new NewNode();
                    foreach (var n in nodes.Take(counter))
                    {
                        currentNode2.AddKeyNode(n.Key, n.Value);
                    }
                    currentNode2.AddKeyNode(node, "[" + key + "]");
                    FlattenedNodes.Add(currentNode2);
                    currentNode = currentNode2;
                }

                if (nodeValue is ArrayNode)
                {
                    var arrayNode = nodeValue as ArrayNode;
                    LoadArrayNode(arrayNode, currentNode, counter + 1);
                }
                else if (nodeValue is KeyArrayNode)
                {
                    var keyArrayNode = nodeValue as KeyArrayNode;
                    LoadKeyArrayNode(keyArrayNode, currentNode, counter + 1);
                }
                else if (nodeValue is KeyValueNode)
                {
                    var keyValueNode = nodeValue as KeyValueNode;
                    LoadKeyValueNode(keyValueNode, currentNode, counter + 1);
                }
                else if (nodeValue is ListKeyValueNode)
                {
                    var listKeyValueNode = nodeValue as ListKeyValueNode;
                    LoadListKeyValueNode(listKeyValueNode, currentNode, counter + 1);
                }
                else if (nodeValue is ValueNode)
                {
                    var valueNode = nodeValue as ValueNode;
                    LoadValueNode(valueNode, currentNode);
                }
                else if (nodeValue == null)
                {
                    var valueNode = new ValueNode();
                    valueNode.Value = "";
                    currentNode.SetValueNode(valueNode);
                }
            }
        }