public bool HasChanges() { var valids = CompareTools.Where(IsValidSetting).ToList(); var containerChanged = !valids.SequenceEqual(_orgContainer.GetCompareTools()); var indexChanged = IsValidSetting(SelectedComapreToolSettings) && valids.IndexOf(SelectedComapreToolSettings) != _orgContainer.CurrentActiveIndex; return(containerChanged || indexChanged); }
public async Task Save() { try { IsProcessing = true; CorrectsCompareToolsWithSelection(); var toRemove = CompareTools.Where(r => !IsValidSetting(r)).ToList(); foreach (var rm in toRemove) { CompareTools.Remove(rm); } // Reverse before distinct so the later one will be kept. var toKeep = CompareTools.Reverse().Distinct().ToArray(); foreach (var tool in CompareTools.ToList()) { if (!toKeep.Contains(tool)) { CompareTools.Remove(tool); } } var newIndx = -1; if (SelectedComapreToolSettings != null) { newIndx = CompareTools.IndexOf(SelectedComapreToolSettings); } var serializable = new CompareToolSettingsContainer(CompareTools, newIndx); await Task.Run(() => _compareToolSettingsPersist.Save(serializable)); } finally { IsProcessing = false; } }