private bool CheckProjectForDuplicateIncludes(ProjectDocument project) { if (project == null) { return(true); } var duplicates = project.Entities.GroupBy(e => e.Name) .Where(g => g.Count() > 1); foreach (var dupe in duplicates) { var dialogModel = new DuplicateObjectsDialogViewModel(dupe.Key, dupe.AsEnumerable()); var dialog = new DuplicateObjectsDialog(); dialog.DataContext = dialogModel; dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { var toRemove = dupe.Where(e => e.StoragePath.Relative != dialogModel.SelectedFile).ToList(); foreach (var entity in toRemove) { if (dialogModel.DeleteDuplicates) { project.RemoveEntity(entity); } else { project.UnloadEntity(entity); } } } else { return(false); } } return(true); }