public static bool RenameElement(this IProductElement element, IToolkitElement toolkitElement, IUriReferenceService uriService, RefactoringManager refactoringManager) { using (new MouseCursor(System.Windows.Input.Cursors.Wait)) { var renameRefactoring = toolkitElement as IRenameRefactoring; if (renameRefactoring != null) { refactoringManager.RenameClass(renameRefactoring.Namespace, renameRefactoring.OriginalInstanceName, renameRefactoring.InstanceName); element.RenameArtifactLinks(uriService, renameRefactoring.OriginalInstanceName, renameRefactoring.InstanceName); return(true); } var renameRefactoringNamespace = toolkitElement as IRenameRefactoringNamespace; if (renameRefactoringNamespace != null && toolkitElement.InstanceName != "" && toolkitElement is IService) { var service = toolkitElement as IService; service.Rename(uriService, refactoringManager); //MessageBox.Show("The Service renaming is almost done. Please, re-open the solution to finish with the renaming.", "Rename Service", MessageBoxButton.OK); return(true); } var renameRefactoringNotSupported = toolkitElement as IRenameRefactoringNotSupported; if (renameRefactoringNotSupported != null && toolkitElement.InstanceName != "") { var result = MessageBox.Show("This element doesn't support code refactoring, you will need to update your code manually. Do you want to do the renaming anyway?", "Rename element", MessageBoxButton.YesNo); return(result == MessageBoxResult.Yes); } return(true); } }
public static bool RenameElement(this IProductElement element, IToolkitElement toolkitElement, IUriReferenceService uriService, RefactoringManager refactoringManager) { using (new MouseCursor(System.Windows.Input.Cursors.Wait)) { var renameRefactoring = toolkitElement as IRenameRefactoring; if (renameRefactoring != null) { refactoringManager.RenameClass(renameRefactoring.Namespace, renameRefactoring.OriginalInstanceName, renameRefactoring.InstanceName); element.RenameArtifactLinks(uriService, renameRefactoring.OriginalInstanceName, renameRefactoring.InstanceName); return true; } var renameRefactoringNamespace = toolkitElement as IRenameRefactoringNamespace; if (renameRefactoringNamespace != null && toolkitElement.InstanceName != "" && toolkitElement is IService) { var service = toolkitElement as IService; service.Rename(uriService, refactoringManager); //MessageBox.Show("The Service renaming is almost done. Please, re-open the solution to finish with the renaming.", "Rename Service", MessageBoxButton.OK); return true; } var renameRefactoringNotSupported = toolkitElement as IRenameRefactoringNotSupported; if (renameRefactoringNotSupported != null && toolkitElement.InstanceName != "") { var result = MessageBox.Show("This element doesn't support code refactoring, you will need to update your code manually. Do you want to do the renaming anyway?", "Rename element", MessageBoxButton.YesNo); return result == MessageBoxResult.Yes; } return true; } }