示例#1
0
        private IDictionary <string, List <File <IReplay> > > NestedSort(ISortCommand SortOnX, IDictionary <string, List <File <IReplay> > > SortOnXResult, List <string> replaysThrowingExceptions)
        {
            // Dictionary<directory, Files>
            IDictionary <string, List <File <IReplay> > > DirectoryFileReplay = new Dictionary <string, List <File <IReplay> > >();

            SortOnX.Sorter.SortCriteria = SortOnX.SortCriteria;
            foreach (var directory in SortOnXResult.Keys)
            {
                var FileReplays = SortOnXResult[directory];
                SortOnX.Sorter.CurrentDirectory = directory;
                SortOnX.Sorter.ListReplays      = FileReplays;
                var result        = SortOnX.Sort(replaysThrowingExceptions);
                var replaysSorted = result.SelectMany(dir => dir.Value);

                if (replaysSorted.Count() != FileReplays.Count())
                {
                    result.Add(directory, FileReplays.Except(replaysSorted).ToList());
                }
                DirectoryFileReplay = DirectoryFileReplay.Concat(result).ToDictionary(k => k.Key, k => k.Value);
            }
            return(DirectoryFileReplay);
        }
示例#2
0
        private IDictionary <string, List <File <IReplay> > > PreviewNestedSort(List <string> replaysThrowingExceptions, ISortCommand SortOnX, IDictionary <string, List <File <IReplay> > > SortOnXResult, BackgroundWorker worker_ReplaySorter, int currentCriteria, int numberOfCriteria)
        {
            IDictionary <string, List <File <IReplay> > > DirectoryFileReplay = new Dictionary <string, List <File <IReplay> > >();

            SortOnX.Sorter.SortCriteria = SortOnX.SortCriteria;
            int currentPostion    = 0;
            int numberOfPositions = SortOnXResult.Keys.Count();

            foreach (var directory in SortOnXResult.Keys)
            {
                currentPostion++;
                var FileReplays = SortOnXResult[directory];
                SortOnX.Sorter.CurrentDirectory = directory;
                SortOnX.Sorter.ListReplays      = FileReplays;
                var result        = SortOnX.PreviewSort(replaysThrowingExceptions, worker_ReplaySorter, currentCriteria, numberOfCriteria, currentPostion, numberOfPositions);
                var replaysSorted = result.SelectMany(dir => dir.Value);

                if (replaysSorted.Count() != FileReplays.Count())
                {
                    result.Add(directory, FileReplays.Except(replaysSorted).ToList());
                }

                if (worker_ReplaySorter.CancellationPending == true)
                {
                    return(null);
                }

                DirectoryFileReplay = DirectoryFileReplay.Concat(result).ToDictionary(k => k.Key, k => k.Value);
            }
            return(DirectoryFileReplay);
        }
示例#3
0
        // not async yet
        private IDictionary <string, List <File <IReplay> > > NestedSortAsync(List <string> replaysThrowingExceptions, ISortCommand SortOnX, IDictionary <string, List <File <IReplay> > > SortOnXResult, BackgroundWorker worker_ReplaySorter, int currentCriteria, int numberOfCriteria)
        {
            // Dictionary<directory, dictionary<file, replay>>
            IDictionary <string, List <File <IReplay> > > DirectoryFileReplay = new Dictionary <string, List <File <IReplay> > >();

            // get replays
            // get files
            // set currentdirectory
            // on sorter
            // for replays and files, need to make return type for sort, which gives a dictionary for replays per directory

            SortOnX.Sorter.SortCriteria = SortOnX.SortCriteria;
            int currentPostion    = 0;
            int numberOfPositions = SortOnXResult.Keys.Count();

            foreach (var directory in SortOnXResult.Keys)
            {
                currentPostion++;
                var FileReplays = SortOnXResult[directory];
                SortOnX.Sorter.CurrentDirectory = directory;
                SortOnX.Sorter.ListReplays      = FileReplays;
                var result        = SortOnX.SortAsync(replaysThrowingExceptions, worker_ReplaySorter, currentCriteria, numberOfCriteria, currentPostion, numberOfPositions);
                var replaysSorted = result.SelectMany(dir => dir.Value);

                if (replaysSorted.Count() != FileReplays.Count())
                {
                    result.Add(directory, FileReplays.Except(replaysSorted).ToList());
                }

                if (worker_ReplaySorter.CancellationPending == true)
                {
                    return(null);
                }

                DirectoryFileReplay = DirectoryFileReplay.Concat(result).ToDictionary(k => k.Key, k => k.Value);
            }
            return(DirectoryFileReplay);
        }