internal static DocumentMapNode CreateNode(IDocumentMap docMap) { if (docMap == null) { return(null); } Stack <NodeStackEntry> stack = new Stack <NodeStackEntry>(); List <DocumentMapNode> workspace = new List <DocumentMapNode>(); OnDemandDocumentMapNode onDemandDocumentMapNode = null; NodeStackEntry item = default(NodeStackEntry); while (docMap.MoveNext()) { onDemandDocumentMapNode = docMap.Current; item.Node = FromOnDemandNode(onDemandDocumentMapNode); item.Level = onDemandDocumentMapNode.Level; while (stack.Count > 0 && onDemandDocumentMapNode.Level < stack.Peek().Level) { CollapseTopLevel(stack, workspace); } stack.Push(item); } while (stack.Count > 1) { CollapseTopLevel(stack, workspace); } return(stack.Pop().Node); }
private static DocumentMapNode FromOnDemandNode(OnDemandDocumentMapNode node) { return(new DocumentMapNode(node.Label, node.Id, null)); }