private bool OkToMoveFolders(MoveMultipleFoldersModel model, string targetFolder) { var foldersMergedWithTargetFolders = FoldersMergedWithTargetFolders(model, targetFolder); return(!foldersMergedWithTargetFolders.Any() || UserConfirmsToProceedWithFolderMerge(targetFolder, foldersMergedWithTargetFolders)); }
private void ValidateInitialFolderModel(MoveMultipleFoldersModel model) { var firstStaleAffectedModules = model.ModulesBySourceFolder.Values .SelectMany(modules => modules) .FirstOrDefault(module => _state.IsNewOrModified(module.QualifiedModuleName)); if (firstStaleAffectedModules != null) { throw new AffectedModuleIsStaleException(firstStaleAffectedModules.QualifiedModuleName); } }
protected override MoveMultipleFoldersModel ModifiedFolderModel(MoveMultipleFoldersModel model, object parameter) { var(targetFolder, node) = (ValueTuple <string, ICodeExplorerNode>)parameter; if (OkToMoveFolders(model, targetFolder)) { model.TargetFolder = targetFolder; } else { throw new RefactoringAbortedException(); } return(model); }
private List <string> FoldersMergedWithTargetFolders(MoveMultipleFoldersModel model, string targetFolder) { var movingFolders = model.ModulesBySourceFolder .Select(kvp => kvp.Key) .Where(folder => !folder.ParentFolder().Equals(targetFolder)) .Select(folder => folder.SubFolderName()); var targetFolderSubfolders = _declarationFinderProvider.DeclarationFinder .UserDeclarations(DeclarationType.Module) .OfType <ModuleDeclaration>() .Select(module => module.CustomFolder) .Where(folder => folder.IsSubFolderOf(targetFolder)) .Select(folder => folder.SubFolderPathRelativeTo(targetFolder).RootFolder()) .ToHashSet(); return(movingFolders .Where(folder => targetFolderSubfolders.Contains(folder)) .ToList()); }
protected abstract MoveMultipleFoldersModel ModifiedFolderModel(MoveMultipleFoldersModel model, object parameter);
protected override MoveMultipleFoldersModel ModifiedFolderModel(MoveMultipleFoldersModel model, object parameter) { return(_moveFoldersInteraction.UserModifiedModel(model)); }
private MoveMultipleFoldersViewModel TestViewModel(MoveMultipleFoldersModel model, IDeclarationFinderProvider declarationFinderProvider, IMessageBox messageBox) { return(new MoveMultipleFoldersViewModel(model, messageBox, declarationFinderProvider)); }