Exemplo n.º 1
0
        /// <summary>
        /// Takes a list of paths and puts them in separate lists, by area and controller.
        /// So all files in Area "Admin" and Controller "Home" go into one list, whilst
        /// all files without Area and Controller "About" go into another list.
        ///
        /// Within the lists, the original order of the files is preserved. So if
        /// the input list contains two files in Area "Admin" and Controller "Home", they are
        /// added to the result list in the same order as in the input list.
        ///
        /// The list of lists is sorted as follows, to ensure that the caller can
        /// place library files (such as jQuery) ahead of other files in the bundles:
        ///
        /// * files with no Area, with controller Shared, and that live in a directory with a name starting with _Layout
        /// * files with no Area, with controller Shared
        /// * files with an Area, with controller Shared, and that live in a directory with a name starting with _Layout
        /// * files with an Area, with controller Shared
        /// * all other files.
        /// </summary>
        /// <param name="filePaths"></param>
        /// <returns></returns>
        public static List <List <AssetPath> > FilePathsSortedByRoute(List <AssetPath> filePaths)
        {
            var filePathsBySortKey = new ListsByKey <AssetPath, string>();

            foreach (AssetPath filePath in filePaths)
            {
                filePathsBySortKey.Add(filePath, FilePathSortKey(filePath));
            }

            var sortedListOfLists = filePathsBySortKey.GetListOfLists();

            sortedListOfLists.Sort((firstPair, nextPair) => firstPair.Key.CompareTo(nextPair.Key));

            List <List <AssetPath> > result = sortedListOfLists.Select(p => p.Value).ToList();

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Takes a list of paths and puts them in separate lists, by area and controller.
        /// So all files in Area "Admin" and Controller "Home" go into one list, whilst
        /// all files without Area and Controller "About" go into another list.
        /// 
        /// Within the lists, the original order of the files is preserved. So if 
        /// the input list contains two files in Area "Admin" and Controller "Home", they are 
        /// added to the result list in the same order as in the input list.
        /// 
        /// The list of lists is sorted as follows, to ensure that the caller can
        /// place library files (such as jQuery) ahead of other files in the bundles:
        /// 
        /// * files with no Area, with controller Shared, and that live in a directory with a name starting with _Layout
        /// * files with no Area, with controller Shared
        /// * files with an Area, with controller Shared, and that live in a directory with a name starting with _Layout
        /// * files with an Area, with controller Shared
        /// * all other files.
        /// </summary>
        /// <param name="filePaths"></param>
        /// <returns></returns>
        public static List<List<AssetPath>> FilePathsSortedByRoute(List<AssetPath> filePaths)
        {
            var filePathsBySortKey = new ListsByKey<AssetPath, string>();

            foreach (AssetPath filePath in filePaths)
            {
                filePathsBySortKey.Add(filePath, FilePathSortKey(filePath));
            }

            var sortedListOfLists = filePathsBySortKey.GetListOfLists();
            sortedListOfLists.Sort((firstPair, nextPair) => firstPair.Key.CompareTo(nextPair.Key));

            List<List<AssetPath>> result = sortedListOfLists.Select(p => p.Value).ToList();
            return result;
        }