예제 #1
0
        private bool TryExport(QualifiedModuleName qualifiedModuleName)
        {
            var component = _projectsRepository.Component(qualifiedModuleName);

            if (component is null)
            {
                return(false); // Edge-case, component already gone.
            }

            if (_vbe.Kind == VBEKind.Standalone && component.IsSaved)
            {
                return(true); // File already up-to-date
            }

            // "Do you want to export '{qualifiedModuleName.Name}' before removing?" (localized)
            var message = string.Format(CodeExplorerUI.ExportBeforeRemove_Prompt, qualifiedModuleName.Name);

            switch (_messageBox.Confirm(message, CodeExplorerUI.ExportBeforeRemove_Caption, ConfirmationOutcome.Yes))
            {
            case ConfirmationOutcome.No:
                // User elected to remove without export, return success.
                return(true);

            case ConfirmationOutcome.Yes:
                if (_exportCommand.PromptFileNameAndExport(qualifiedModuleName))
                {
                    // Export complete
                    return(true);
                }
                break;
            }

            return(false); // Save dialog cancelled or export failed (failures will have already been displayed and logged by this point)
        }