Exemplo n.º 1
0
        public override void DefaultVisit(TreeNodeViewModel node)
        {
            if (node == null || SortContext == null)
            {
                return;
            }

            node.ChildrenSortType      = SortContext.SortType;
            node.ChildrenSortDirection = SortContext.SortDirection;

            if (node.Children.Count == 0)
            {
                return;
            }
            else if (node.Children.Count > 1)              //Optimization for single element collections - do not sort and reset them
            {
                var sorted = NodesSorter.SortNodes(node.Children, SortContext.SortType, SortContext.SortDirection)
                             ?.ToList(capacity: node.Children.Count)
                             ?? Enumerable.Empty <TreeNodeViewModel>();

                node.Children.Reset(sorted);
            }

            if (SortContext.SortDescendants)
            {
                base.DefaultVisit(node);
            }
        }
        public override List <TreeNodeViewModel> DefaultVisit(TreeNodeViewModel node, IEnumerable <TreeNodeViewModel> generatedChildren)
        {
            if (node == null)
            {
                return(base.DefaultVisit(node, generatedChildren));
            }

            node.ChildrenSortType      = SortType;
            node.ChildrenSortDirection = SortDirection;

            return(!generatedChildren.IsNullOrEmpty()
                                ? NodesSorter.SortNodes(generatedChildren, SortType, SortDirection)
                                : base.DefaultVisit(node, generatedChildren));
        }
Exemplo n.º 3
0
 public CodeMapSubtreeSorter(NodesSorter nodesSorter = null)
 {
     NodesSorter = nodesSorter ?? new NodesSorter();
 }
        public CodeMapTreeInitialSorter(SortType defaultSortType, SortDirection defaultSortDirection, NodesSorter nodesSorter = null) :
            base(defaultValue: new List <TreeNodeViewModel>())
        {
            NodesSorter = nodesSorter ?? new NodesSorter();

            SortType      = defaultSortType;
            SortDirection = defaultSortDirection;
        }