Example #1
0
        protected bool Insert(Node node, TreeManager.DoPreInsertoinProcessingDelegate doPreInsertionProcessing, TreeManager.DoPostInsertionProcessingDelegate doPostInsertionProcessing)
        {
            bool flag;
            Node node2 = this.FindParent(node.ParentKey, node, out flag);

            if (node2 == null)
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Cannot insert node because no suitable parent with key {0} is found.", node.ParentKey);
                return(false);
            }
            if (doPreInsertionProcessing != null && !doPreInsertionProcessing(node2, node))
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string, string>(this.GetHashCode(), "node {0} not inserted based on shouldChildrenBeInsertedUnderParent check for parent node {1}", node.Key, node2.Key);
                return(false);
            }
            bool flag2 = this.InsertChildUnderParent(node2, node, doPreInsertionProcessing, doPostInsertionProcessing);

            if (flag2 && !flag)
            {
                this.RemoveNodeFromLeafRecords(node2);
            }
            return(true);
        }
Example #2
0
        protected bool InsertAllChildrenForOneNode(string parentKey, IList <Node> nodes, TreeManager.DoPreInsertoinProcessingDelegate doPreInsertionProcessing, TreeManager.DoPostInsertionProcessingDelegate doPostInsertionProcessing)
        {
            if (nodes == null || nodes.Count == 0)
            {
                return(this.RemoveKeyFromLeafSet(parentKey));
            }
            bool flag;
            Node node = this.FindParent(parentKey, nodes[0], out flag);

            if (node == null)
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Cannot insert any children because no suitable parent with key {0} is found.", parentKey);
                return(false);
            }
            bool flag2 = false;

            foreach (Node childNode in nodes)
            {
                if (this.InsertChildUnderParent(node, childNode, doPreInsertionProcessing, doPostInsertionProcessing))
                {
                    flag2 = true;
                }
            }
            if (flag2 && !flag)
            {
                this.RemoveNodeFromLeafRecords(node);
            }
            return(true);
        }
Example #3
0
        private bool InsertChildUnderParent(Node parentNode, Node childNode, TreeManager.DoPreInsertoinProcessingDelegate doPreInsertionProcessing, TreeManager.DoPostInsertionProcessingDelegate doPostInsertionProcessing)
        {
            if (doPreInsertionProcessing != null && !doPreInsertionProcessing(parentNode, childNode))
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <string, string>(this.GetHashCode(), "node list with first node {0} not inserted based on pre insertion check for parent node {1}", childNode.Key, parentNode.Key);
                return(false);
            }
            parentNode.AddChild(childNode);
            Node node = doPostInsertionProcessing(parentNode, childNode);

            this.InsertLeafNode(node);
            return(true);
        }