/// <summary> /// Analyzes the mods asynchronous. /// </summary> /// <param name="id">The identifier.</param> /// <param name="mode">The mode.</param> /// <returns>Task.</returns> protected virtual async Task AnalyzeModsAsync(long id, PatchStateMode mode) { SubscribeToProgressReport(id, Disposables); var overlayProgress = Smart.Format(localizationManager.GetResource(LocalizationResources.Mod_Actions.ConflictSolver.Overlay_Conflict_Solver_Progress), new { PercentDone = 0.ToLocalizedPercentage(), Count = 1, TotalCount = 4 }); var message = localizationManager.GetResource(LocalizationResources.Mod_Actions.ConflictSolver.Overlay_Conflict_Solver_Loading_Definitions); await TriggerOverlayAsync(id, true, message, overlayProgress); modPatchCollectionService.InvalidatePatchModState(CollectionMods.SelectedModCollection.Name); modPatchCollectionService.ResetPatchStateCache(); var definitions = await Task.Run(async() => { return(await modPatchCollectionService.GetModObjectsAsync(gameService.GetSelected(), CollectionMods.SelectedMods, CollectionMods.SelectedModCollection.Name).ConfigureAwait(false)); }).ConfigureAwait(false); var conflicts = await Task.Run(() => { if (definitions != null) { return(modPatchCollectionService.FindConflicts(definitions, CollectionMods.SelectedMods.Select(p => p.Name).ToList(), mode)); } return(null); }).ConfigureAwait(false); var syncedConflicts = await Task.Run(async() => { return(await modPatchCollectionService.InitializePatchStateAsync(conflicts, CollectionMods.SelectedModCollection.Name).ConfigureAwait(false)); }).ConfigureAwait(false); if (syncedConflicts != null) { conflicts = syncedConflicts; } var args = new NavigationEventArgs() { SelectedCollection = CollectionMods.SelectedModCollection, Results = conflicts, State = NavigationState.ConflictSolver, SelectedMods = CollectionMods.SelectedMods.Select(p => p.Name).ToList() }; ReactiveUI.MessageBus.Current.SendMessage(args); await TriggerOverlayAsync(id, false); definitionAnalyzeLoadHandler?.Dispose(); definitionLoadHandler?.Dispose(); definitionSyncHandler?.Dispose(); // I know, I know... but I wanna force a cleanup GC.Collect(); }
/// <summary> /// Analyzes the mods asynchronous. /// </summary> /// <param name="id">The identifier.</param> /// <param name="mode">The mode.</param> /// <param name="versions">The versions.</param> /// <returns>Task.</returns> protected virtual async Task AnalyzeModsAsync(long id, PatchStateMode mode, IEnumerable <string> versions) { var totalSteps = versions != null && versions.Any() ? 6 : 4; SubscribeToProgressReport(id, Disposables, totalSteps); var overlayProgress = Smart.Format(localizationManager.GetResource(LocalizationResources.Mod_Actions.ConflictSolver.Overlay_Conflict_Solver_Progress), new { PercentDone = 0.ToLocalizedPercentage(), Count = 1, TotalCount = totalSteps }); var message = localizationManager.GetResource(LocalizationResources.Mod_Actions.ConflictSolver.Overlay_Conflict_Solver_Loading_Definitions); await TriggerOverlayAsync(id, true, message, overlayProgress); modPatchCollectionService.InvalidatePatchModState(CollectionMods.SelectedModCollection.Name); modPatchCollectionService.ResetPatchStateCache(); var game = gameService.GetSelected(); var definitions = await Task.Run(async() => { var result = await modPatchCollectionService.GetModObjectsAsync(gameService.GetSelected(), CollectionMods.SelectedMods, CollectionMods.SelectedModCollection.Name).ConfigureAwait(false); // To stop people from whining GC.Collect(); return(result); }).ConfigureAwait(false); if (versions != null && versions.Any()) { await Task.Run(async() => { await gameIndexService.IndexDefinitionsAsync(game, versions, definitions); // To stop people from whining GC.Collect(); }); definitions = await Task.Run(async() => { var result = await gameIndexService.LoadDefinitionsAsync(definitions, game, versions); // To stop people from whining GC.Collect(); return(result); }).ConfigureAwait(false); } var conflicts = await Task.Run(() => { if (definitions != null) { // To stop people from whining var result = modPatchCollectionService.FindConflicts(definitions, CollectionMods.SelectedMods.Select(p => p.Name).ToList(), mode); GC.Collect(); return(result); } return(null); }).ConfigureAwait(false); var syncedConflicts = await Task.Run(async() => { var result = await modPatchCollectionService.InitializePatchStateAsync(conflicts, CollectionMods.SelectedModCollection.Name).ConfigureAwait(false); // To stop people from whining GC.Collect(); return(result); }).ConfigureAwait(false); if (syncedConflicts != null) { conflicts = syncedConflicts; } var args = new NavigationEventArgs() { SelectedCollection = CollectionMods.SelectedModCollection, Results = conflicts, State = mode == PatchStateMode.ReadOnly ? NavigationState.ReadOnlyConflictSolver : NavigationState.ConflictSolver, SelectedMods = CollectionMods.SelectedMods.Select(p => p.Name).ToList() }; ReactiveUI.MessageBus.Current.SendMessage(args); await TriggerOverlayAsync(id, false); definitionAnalyzeLoadHandler?.Dispose(); definitionLoadHandler?.Dispose(); definitionSyncHandler?.Dispose(); gameIndexHandler?.Dispose(); gameDefinitionLoadHandler?.Dispose(); // I know, I know... but I wanna force a cleanup GC.Collect(); }