/// <summary>
        /// Builds graph with chunk root nodes
        /// </summary>
        /// <returns></returns>
        public NodeGraph BuildChunkRootsGraph()
        {
            List <LeafNodeDictionaryEntry> rootEntries = new List <LeafNodeDictionaryEntry>();
            Dictionary <LeafNodeDictionaryEntry, ContentChunk> EntryChunkDictionary = new Dictionary <LeafNodeDictionaryEntry, ContentChunk>();

            foreach (var chunk in items)
            {
                LeafNodeDictionaryEntry entry = null;
                if (chunk.RootNode != null)
                {
                    entry = new LeafNodeDictionaryEntry(chunk.RootNode);
                }
                else
                {
                    entry = new LeafNodeDictionaryEntry()
                    {
                        XPath = chunk.XPathRoot
                    };
                }

                EntryChunkDictionary.Add(entry, chunk);
                rootEntries.Add(entry);
            }

            NodeGraph graph = NodeGraph.Build(rootEntries);

            foreach (var pair in EntryChunkDictionary)
            {
                NodeGraph chunkChild = graph.GetChildAtPath <NodeGraph>(pair.Key.XPath);
                chunkChild.SetMetaData(pair.Value);
            }

            return(graph);
        }
Beispiel #2
0
        public void ConstructParentEntries()
        {
            var allChildren = this.getAllChildren(null, false, false, 1, 500, true);

            List <LeafNodeDictionaryEntry> Items = new List <LeafNodeDictionaryEntry>();

            Dictionary <String, HtmlNode> toAssign = new Dictionary <string, HtmlNode>();

            foreach (NodeGraph child in allChildren)
            {
                if (child.item != null)
                {
                    LeafNodeDictionaryEntry entry = child.item;

                    if (entry.node != null)
                    {
                        if (entry.node.ParentNode != null)
                        {
                            String xpath = entry.node.ParentNode.XPath;

                            if (!toAssign.ContainsKey(xpath))
                            {
                                toAssign.Add(xpath, entry.node.ParentNode);
                            }
                        }
                    }

                    Items.Add(child.item);
                }
            }

            NodeGraph rootGraph = root as NodeGraph;

            foreach (var pair in toAssign)
            {
                LeafNodeDictionaryEntry entry = new LeafNodeDictionaryEntry()
                {
                    XPath    = pair.Key,
                    node     = pair.Value,
                    Category = NodeInTemplateRole.Structural,
                };
                var graph_node = rootGraph.GetChildAtPath(pair.Key, "/");
                graph_node.SetItem(entry);
            }
        }