示例#1
0
        NodeInfo CreateViewNode(IView view, NodesCollectionInfo collectionToAddViewNode, IInspectedObject modelNode, int level, List <NodeInfo> nodesToCollapse)
        {
            string nodeText = modelNode.Id;

            if (modelNode.DisplayId != "")
            {
                nodeText += " (" + modelNode.DisplayId + ")";
            }

            bool createCollapsed    = false;
            bool createLazilyLoaded = false;

            if (level == 1)
            {
                if (OnNodeCreated != null)
                {
                    var args = new NodeCreatedEventArgs()
                    {
                        NodeObject = modelNode
                    };
                    OnNodeCreated(this, args);
                    createCollapsed    = args.CreateCollapsed.GetValueOrDefault(createCollapsed);
                    createLazilyLoaded = args.CreateLazilyLoaded.GetValueOrDefault(createLazilyLoaded);
                }
                if (createLazilyLoaded && !view.TreeSupportsLoadingOnExpansion)
                {
                    createLazilyLoaded = false;
                }
            }

            var viewNode = view.CreateNode(nodeText, modelNode, collectionToAddViewNode);

            if (createLazilyLoaded)
            {
                view.CreateNode(lazyLoadTag, lazyLoadTag, viewNode.ChildrenNodesCollection);
            }
            else
            {
                foreach (var child in modelNode.Children)
                {
                    CreateViewNode(view, viewNode.ChildrenNodesCollection, child, level + 1, nodesToCollapse);
                }
            }
            if (createCollapsed)
            {
                nodesToCollapse.Add(viewNode);
            }
            return(viewNode);
        }