/// <summary> /// Sets the conflict result. /// </summary> /// <param name="conflictResult">The conflict result.</param> /// <param name="activeMods">The active mods.</param> /// <param name="collectionName">Name of the collection.</param> public virtual void SetConflictResult(IConflictResult conflictResult, IReadOnlyList <string> activeMods, string collectionName) { async Task valuesSet() { await Task.Delay(50); settingValues = false; } this.collectionName = collectionName; ConflictResult = conflictResult; previousIgnoredPath = conflictResult?.IgnoredPaths ?? string.Empty; isOpen?.Dispose(); isOpen = this.WhenAnyValue(p => p.IsOpen).Where(p => p).Subscribe(s => { settingValues = true; Mods.Clear(); SelectedMods.Clear(); Mods.AddRange(activeMods.Select(p => new Mod() { Name = p })); var ignoredMods = modPatchCollectionService.GetIgnoredMods(ConflictResult).Select(p => new Mod() { Name = p }).ToList(); var selectedMods = Mods.ToList().Except(ignoredMods); SelectedMods.AddRange(selectedMods); shouldToggleGameMods = false; previousIgnoreGameMods = IgnoreGameMods = modPatchCollectionService.ShouldIgnoreGameMods(conflictResult).GetValueOrDefault(); valuesSet().ConfigureAwait(false); }).DisposeWith(Disposables); }
/// <summary> /// Sets the conflict result. /// </summary> /// <param name="conflictResult">The conflict result.</param> /// <param name="activeMods">The active mods.</param> /// <param name="collectionName">Name of the collection.</param> public virtual void SetConflictResult(IConflictResult conflictResult, IReadOnlyList <string> activeMods, string collectionName) { this.collectionName = collectionName; ConflictResult = conflictResult; previousIgnoredPath = conflictResult.IgnoredPaths; isOpen?.Dispose(); isOpen = this.WhenAnyValue(p => p.IsOpen).Where(p => p).Subscribe(s => { Mods.Clear(); SelectedMods.Clear(); Mods.AddRange(activeMods); SelectedMods.AddRange(activeMods.Except(modPatchCollectionService.GetIgnoredMods(ConflictResult)).ToList()); }).DisposeWith(Disposables); }
/// <summary> /// merge collection as an asynchronous operation. /// </summary> /// <param name="conflictResult">The conflict result.</param> /// <param name="modOrder">The mod order.</param> /// <param name="collectionName">Name of the collection.</param> /// <returns>Task<IMod>.</returns> public virtual async Task <IMod> MergeCollectionByDefinitionsAsync(IConflictResult conflictResult, IList <string> modOrder, string collectionName) {
/// <summary> /// Sets the parameters. /// </summary> /// <param name="conflictResult">The conflict result.</param> public void SetParameters(IConflictResult conflictResult) { ConflictResult = conflictResult; }
public static ConflictException Conflict(this IConflictResult result) { return(default);
/// <summary> /// Sets the parameters. /// </summary> /// <param name="conflictResult">The conflict result.</param> /// <param name="collectionName">Name of the collection.</param> public virtual void SetParameters(IConflictResult conflictResult, string collectionName) { Conflicts = conflictResult; CollectionName = collectionName; Bind(GetHierarchicalDefinitions(SelectedMode)); }
/// <summary> /// Filters the hierarchal conflicts asynchronous. /// </summary> /// <param name="conflictResult">The conflict result.</param> /// <param name="selectedDefinitionOverride">The selected definition override.</param> /// <returns>Task.</returns> protected virtual async Task FilterHierarchalConflictsAsync(IConflictResult conflictResult, IHierarchicalDefinitions selectedDefinitionOverride = null) { while (filteringConflicts) { await Task.Delay(25); } filteringConflicts = true; var index = PreviousConflictIndex; PreviousConflictIndex = null; if (conflictResult != null && conflictResult.Conflicts != null) { var conflicts = conflictResult.Conflicts.GetHierarchicalDefinitions().ToList(); var resolved = new List <IHierarchicalDefinitions>(); if (conflictResult.ResolvedConflicts != null) { resolved.AddRange(conflictResult.ResolvedConflicts.GetHierarchicalDefinitions()); } if (conflictResult.IgnoredConflicts != null) { resolved.AddRange(conflictResult.IgnoredConflicts.GetHierarchicalDefinitions()); } if (conflictResult.RuleIgnoredConflicts != null) { resolved.AddRange(conflictResult.RuleIgnoredConflicts.GetHierarchicalDefinitions()); } foreach (var topLevelResolvedConflicts in resolved) { IEnumerable <IHierarchicalDefinitions> topLevelConflicts; if (topLevelResolvedConflicts.Name.StartsWith(LocalizationDirectory, StringComparison.OrdinalIgnoreCase)) { topLevelConflicts = conflicts.Where(p => p.Name.StartsWith(LocalizationDirectory, StringComparison.OrdinalIgnoreCase)); } else { topLevelConflicts = conflicts.Where(p => p.Name.Equals(topLevelResolvedConflicts.Name)); } if (topLevelConflicts.Any()) { foreach (var topLevelConflict in topLevelConflicts) { foreach (var childResolvedConflict in topLevelResolvedConflicts.Children) { var child = topLevelConflict.Children.FirstOrDefault(p => p.Key.Equals(childResolvedConflict.Key)); if (child != null) { topLevelConflict.Children.Remove(child); } } } } conflicts.RemoveAll(p => p.Children == null || p.Children.Count == 0); } var invalid = conflictResult.AllConflicts.GetByValueType(ValueType.Invalid); if (invalid?.Count() > 0) { var invalidDef = DIResolver.Get <IHierarchicalDefinitions>(); invalidDef.Name = Invalid; invalidDef.Key = InvalidKey; var children = new List <IHierarchicalDefinitions>(); foreach (var item in invalid) { var invalidChild = DIResolver.Get <IHierarchicalDefinitions>(); invalidChild.Name = item.File; var message = item.ErrorColumn.HasValue || item.ErrorLine.HasValue ? localizationManager.GetResource(LocalizationResources.Conflict_Solver.InvalidConflicts.Error) : localizationManager.GetResource(LocalizationResources.Conflict_Solver.InvalidConflicts.ErrorNoLine); invalidChild.Key = Smart.Format(message, new { item.ModName, Line = item.ErrorLine, Column = item.ErrorColumn, Environment.NewLine, Message = item.ErrorMessage, item.File }); invalidChild.AdditionalData = item; children.Add(invalidChild); } invalidDef.Children = children; conflicts.Add(invalidDef); } HierarchalConflicts = conflicts.ToObservableCollection(); NumberOfConflictsCaption = Smart.Format(localizationManager.GetResource(LocalizationResources.Conflict_Solver.ConflictCount), new { Count = conflicts.Where(p => p.Key != InvalidKey).SelectMany(p => p.Children).Count() }); if (HierarchalConflicts.Any() && SelectedParentConflict == null) { SelectedParentConflict = HierarchalConflicts.FirstOrDefault(); } if (SelectedParentConflict != null) { var conflictName = SelectedParentConflict.Name; SelectedParentConflict = null; var newSelected = HierarchalConflicts.FirstOrDefault(p => p.Name.Equals(conflictName)); if (newSelected != null) { PreviousConflictIndex = index; if (selectedDefinitionOverride != null) { var overrideMatch = newSelected.Children.FirstOrDefault(p => p.Key.Equals(selectedDefinitionOverride.Key)); if (overrideMatch != null) { PreviousConflictIndex = newSelected.Children.ToList().IndexOf(overrideMatch); } } if (PreviousConflictIndex.GetValueOrDefault() > (newSelected.Children.Count - 1)) { PreviousConflictIndex = newSelected.Children.Count - 1; } SelectedParentConflict = newSelected; } } } else { HierarchalConflicts = null; } filteringConflicts = false; }
/// <summary> /// Sets the parameters. /// </summary> /// <param name="conflictResult">The conflict result.</param> /// <param name="collectionName">Name of the collection.</param> public virtual void SetParameters(IConflictResult conflictResult, string collectionName) { ConflictResult = conflictResult; CollectionName = collectionName; promptShown = false; }