Example #1
0
 /// <summary>
 /// Clears any hierarchy information from the specified code items.
 /// </summary>
 /// <param name="codeItems">The code items.</param>
 private static void ClearHierarchyInformation(SetCodeItems codeItems)
 {
     foreach (var codeItem in codeItems.OfType<ICodeItemParent>())
     {
         codeItem.Children.Clear();
     }
 }
Example #2
0
 /// <summary>
 /// Clears any hierarchy information from the specified code items.
 /// </summary>
 /// <param name="codeItems">The code items.</param>
 private static void ClearHierarchyInformation(SetCodeItems codeItems)
 {
     foreach (var codeItem in codeItems.OfType <ICodeItemParent>())
     {
         codeItem.Children.Clear();
     }
 }
Example #3
0
        /// <summary>
        /// Recursively sorts the specified code items by the specified sort comparer.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        /// <param name="sortComparer">The sort comparer.</param>
        private static void RecursivelySort(SetCodeItems codeItems, IComparer <BaseCodeItem> sortComparer)
        {
            codeItems.Sort(sortComparer);

            foreach (var codeItem in codeItems.OfType <ICodeItemParent>())
            {
                RecursivelySort(codeItem.Children, sortComparer);
            }
        }
Example #4
0
        /// <summary>
        /// Recursively retrives all code item parents within the specified code items.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        /// <returns>The code item parents.</returns>
        private static IEnumerable <ICodeItemParent> RecursivelyGetAllCodeItemParents(SetCodeItems codeItems)
        {
            if (codeItems == null)
            {
                return(Enumerable.Empty <ICodeItemParent>());
            }

            var parents = codeItems.OfType <ICodeItemParent>().ToList();

            return(parents.Union(parents.SelectMany(x => RecursivelyGetAllCodeItemParents(x.Children))));
        }
Example #5
0
        /// <summary>
        /// Organizes the specified code items by type sort order.
        /// </summary>
        /// <param name="rawCodeItems">The raw code items.</param>
        /// <returns>The organized code items.</returns>
        private static SetCodeItems OrganizeCodeItemsByTypeSortOrder(SetCodeItems rawCodeItems)
        {
            var organizedCodeItems = new SetCodeItems();

            if (rawCodeItems != null)
            {
                var codeItemsWithoutRegions = rawCodeItems.Where(x => !(x is CodeItemRegion));

                var structuredCodeItems = OrganizeCodeItemsByFileSortOrder(codeItemsWithoutRegions);
                organizedCodeItems.AddRange(structuredCodeItems);

                // Sort the list of code items by type recursively.
                RecursivelySort(organizedCodeItems, new CodeItemTypeComparer());

                // Group the list of code items by type recursively.
                foreach (var codeItem in organizedCodeItems.OfType <ICodeItemParent>())
                {
                    RecursivelyGroupByType(codeItem);
                }
            }

            return(organizedCodeItems);
        }
Example #6
0
        /// <summary>
        /// Recursively sorts the specified code items by the specified sort comparer.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        /// <param name="sortComparer">The sort comparer.</param>
        private static void RecursivelySort(SetCodeItems codeItems, IComparer<BaseCodeItem> sortComparer)
        {
            codeItems.Sort(sortComparer);

            foreach (var codeItem in codeItems.OfType<ICodeItemParent>())
            {
                RecursivelySort(codeItem.Children, sortComparer);
            }
        }
Example #7
0
        /// <summary>
        /// Organizes the specified code items by type sort order.
        /// </summary>
        /// <param name="rawCodeItems">The raw code items.</param>
        /// <returns>The organized code items.</returns>
        private static SetCodeItems OrganizeCodeItemsByTypeSortOrder(SetCodeItems rawCodeItems)
        {
            var organizedCodeItems = new SetCodeItems();

            if (rawCodeItems != null)
            {
                var codeItemsWithoutRegions = rawCodeItems.Where(x => !(x is CodeItemRegion));

                var structuredCodeItems = OrganizeCodeItemsByFileSortOrder(codeItemsWithoutRegions);
                organizedCodeItems.AddRange(structuredCodeItems);

                // Sort the list of code items by type recursively.
                RecursivelySort(organizedCodeItems, new CodeItemTypeComparer());

                // Group the list of code items by type recursively.
                foreach (var codeItem in organizedCodeItems.OfType<ICodeItemParent>())
                {
                    RecursivelyGroupByType(codeItem);
                }
            }

            return organizedCodeItems;
        }
        /// <summary>
        /// Recursively retrives all code item parents within the specified code items.
        /// </summary>
        /// <param name="codeItems">The code items.</param>
        /// <returns>The code item parents.</returns>
        private static IEnumerable<ICodeItemParent> RecursivelyGetAllCodeItemParents(SetCodeItems codeItems)
        {
            if (codeItems == null)
            {
                return Enumerable.Empty<ICodeItemParent>();
            }

            var parents = codeItems.OfType<ICodeItemParent>().ToList();

            return parents.Union(parents.SelectMany(x => RecursivelyGetAllCodeItemParents(x.Children)));
        }