private bool OkToMoveFolders(MoveMultipleFoldersModel model, string targetFolder)
        {
            var foldersMergedWithTargetFolders = FoldersMergedWithTargetFolders(model, targetFolder);

            return(!foldersMergedWithTargetFolders.Any() ||
                   UserConfirmsToProceedWithFolderMerge(targetFolder, foldersMergedWithTargetFolders));
        }
コード例 #2
0
        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());
        }
コード例 #5
0
 protected abstract MoveMultipleFoldersModel ModifiedFolderModel(MoveMultipleFoldersModel model, object parameter);
コード例 #6
0
 protected override MoveMultipleFoldersModel ModifiedFolderModel(MoveMultipleFoldersModel model, object parameter)
 {
     return(_moveFoldersInteraction.UserModifiedModel(model));
 }
コード例 #7
0
 private MoveMultipleFoldersViewModel TestViewModel(MoveMultipleFoldersModel model, IDeclarationFinderProvider declarationFinderProvider, IMessageBox messageBox)
 {
     return(new MoveMultipleFoldersViewModel(model, messageBox, declarationFinderProvider));
 }