public DirectoryFileTree PreviewSort(bool keepOriginalReplayNames, BackgroundWorker worker_ReplaySorter, List <string> replaysThrowingExceptions) { ReplayHandler.SaveReplayFilePaths(OriginalListReplays); IDictionary <string, List <File <IReplay> > > SortOnXResult = new Dictionary <string, List <File <IReplay> > >(); for (int i = 0; i < CriteriaStringOrder.Length; i++) { var SortOnX = Factory.GetSortCommand((Criteria)Enum.Parse(typeof(Criteria), CriteriaStringOrder[i]), SortCriteriaParameters, i == 0 ? keepOriginalReplayNames : true, this); if (i == 0) { SortOnXResult = SortOnX.PreviewSort(replaysThrowingExceptions, worker_ReplaySorter, i + 1, CriteriaStringOrder.Count()); if (worker_ReplaySorter.CancellationPending == true) { return(null); } } else { SortOnX.IsNested = true; SortOnXResult = PreviewNestedSort(replaysThrowingExceptions, SortOnX, SortOnXResult, worker_ReplaySorter, i + 1, CriteriaStringOrder.Count()); if (worker_ReplaySorter.CancellationPending == true) { return(null); } } } // lazy... worker_ReplaySorter.ReportProgress(100, "Building tree..."); var tree = BuildTree(SortOnXResult); ReplayHandler.RestoreToSavedStateAndClearFuture(OriginalListReplays); return(tree); }
public DirectoryFileTree ExecuteSortAsync(bool keeporiginalreplaynames, BackgroundWorker worker_ReplaySorter, List <string> replaysThrowingExceptions) { ReplayHandler.SaveReplayFilePaths(OriginalListReplays); // Sort Result ! // DirectoryFileTree<File<IReplay>> TotalSortResult = new DirectoryFileTree<File<IReplay>>(new DirectoryInfo(OriginalDirectory)); // why do i need this silly string array with the original order... IDictionary <string, List <File <IReplay> > > SortOnXResult = new Dictionary <string, List <File <IReplay> > >(); for (int i = 0; i < CriteriaStringOrder.Length; i++) { // should I pass a new sorter instead of this?? Then I don't have to make separate property OriginalDirectory var SortOnX = Factory.GetSortCommand((Criteria)Enum.Parse(typeof(Criteria), CriteriaStringOrder[i]), SortCriteriaParameters, i == 0 ? keeporiginalreplaynames : true, this); if (i == 0) { SortOnXResult = SortOnX.SortAsync(replaysThrowingExceptions, worker_ReplaySorter, i + 1, CriteriaStringOrder.Count()); if (worker_ReplaySorter.CancellationPending == true) { return(null); } } else { // nested sort SortOnX.IsNested = true; SortOnXResult = NestedSortAsync(replaysThrowingExceptions, SortOnX, SortOnXResult, worker_ReplaySorter, i + 1, CriteriaStringOrder.Count()); if (worker_ReplaySorter.CancellationPending == true) { return(null); } } } // lazy... worker_ReplaySorter.ReportProgress(100, "Building tree..."); var tree = BuildTree(SortOnXResult); ReplayHandler.RestoreToSavedStateAndClearFuture(OriginalListReplays); return(tree); }