Ejemplo n.º 1
0
        /// <summary>
        /// Removes preceding, trailing and duplicate separators from each level of the tree
        /// </summary>
        /// <returns>new tree instance with redundant separator nodes removed</returns>
        public UITree RemoveRedundantSeparators()
        {
            var tree = new UITree();

            Map(this, tree, MapWithRemoveRedundantSeparators);
            return(tree);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Flattens group nodes in the tree and instead inserts preceding and trailing separators
        /// </summary>
        /// <returns>new tree instance with flattened group nodes</returns>
        public UITree FlattenGroups()
        {
            var tree = new UITree();

            Map(this, tree, MapWithFlatteningGroups);
            return(tree);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes groups and named groups not containing elements from the tree
        /// </summary>
        /// <returns>new tree instance with empty group nodes removed</returns>
        public UITree RemoveEmptyGroups()
        {
            var tree = new UITree();

            Map(this, tree, MapWithRemoveEmptyGroups);
            return(tree);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets tree with only entity roots, ignoring all other tree nodes
        /// </summary>
        /// <returns>new tree instance with just entity roots</returns>
        public UITree GetEntityRootsTree()
        {
            var tree = new UITree();

            Map(this, tree, MapWithGetOnlyEntityRoots);
            return(tree);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Maps current tree instance using the specified mapping function and returns newly created mapped tree
        /// </summary>
        /// <param name="mappingFunction">mapping function</param>
        /// <returns>new mapped tree instance</returns>
        public UITree Map(Func <List <IUITreeNode>, List <UITreeNode> > mappingFunction)
        {
            if (mappingFunction == null)
            {
                throw new MemoryPointerIsNullException("mappingFunction");
            }

            var tree = new UITree();

            Map(this, tree, mappingFunction);
            return(tree);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates new instance of <see cref="UITree"/> by copying from the specified source and using entity mappings
        /// </summary>
        /// <typeparam name="TSourceEntity">entity type in current tree</typeparam>
        /// <typeparam name="TDestinationEntity">entity type in mapped tree</typeparam>
        /// <param name="sourceTree">source tree</param>
        /// <param name="entityMappingFunction">entity mapping function</param>
        /// <returns>new tree instance with entity nodes of new type</returns>
        public static UITree Create <TSourceEntity, TDestinationEntity>(IUITree sourceTree, Func <TSourceEntity, TDestinationEntity> entityMappingFunction)
        {
            if (sourceTree == null)
            {
                throw new MemoryPointerIsNullException("sourceTree");
            }

            if (entityMappingFunction == null)
            {
                throw new MemoryPointerIsNullException("entityMappingFunction");
            }

            var tree = new UITree();

            MapEntityNodes(sourceTree, tree, entityMappingFunction);
            return(tree);
        }
Ejemplo n.º 7
0
 private static void MapEntityNodes <TSourceEntity, TDestinationEntity>(
     IUITree sourceTree, UITree destinationTree, Func <TSourceEntity, TDestinationEntity> entityMappingFunction)
 {
     destinationTree.Roots.AddRange(MapWithConvertEntityNodes(sourceTree.GetRoots(), entityMappingFunction));
 }
Ejemplo n.º 8
0
 private static void Map(IUITree sourceTree, UITree destinationTree, Func <List <IUITreeNode>, List <UITreeNode> > mappingFunction)
 {
     destinationTree.Roots.AddRange(mappingFunction(sourceTree.GetRoots()));
 }