private static string CommandErrorMessage(this IProjectCommand source)
        {
            CultureInfo currentCulture             = CultureInfo.CurrentCulture;
            string      commandFailedDialogMessage = StringTable.CommandFailedDialogMessage;

            object[] displayName = new object[] { source.DisplayName };
            return(string.Format(currentCulture, commandFailedDialogMessage, displayName));
        }
        public static void DisplayCommandFailedMessage(this IProjectCommand source, string failureMessage)
        {
            IMessageDisplayService messageDisplayService = source.Services.MessageDisplayService();

            if (messageDisplayService != null)
            {
                messageDisplayService.ShowError(failureMessage);
            }
        }
        public static bool SaveSolution(this IProjectCommand source, bool promptBeforeSaving, bool saveActiveDocument)
        {
            ISolutionManagement solutionManagement = source.Services.SolutionManagement();

            if (solutionManagement == null)
            {
                return(false);
            }
            return(solutionManagement.Save(promptBeforeSaving, saveActiveDocument));
        }
Esempio n. 4
0
        public static void VerifyPermission(this IProjectCommand command, IServiceProvider serviceProvider)
        {
            var permission = GetPermissionCurrentUserCurrentProject(serviceProvider);

            if (permission == null)
            {
                throw new PermissionException(Sentences.youDontHavePermissionToAccessThisProject);
            }

            if (permission.Profile != Profile.Editor && permission.Profile != Profile.ProjectOwner)
            {
                throw new PermissionException(Sentences.youMustHaveEditorPermissionForThisProjectToExecuteThisAction);
            }
        }
 public static IEnumerable <IDocumentItem> Selection(this IProjectCommand source)
 {
     return(source.Services.Selection());
 }
 public static IEnumerable <IProject> SelectedProjects(this IProjectCommand source)
 {
     return(source.Services.SelectedProjects());
 }
 public static IProject SelectedProjectOrNull(this IProjectCommand source)
 {
     return(source.Services.SelectedProjects().SingleOrNull <IProject>());
 }
 public static IProjectItem SelectedProjectItemOrNull(this IProjectCommand source)
 {
     return(source.Services.Selection().SingleOrNull <IDocumentItem>() as IProjectItem);
 }
 public static IProjectManager ProjectManager(this IProjectCommand source)
 {
     return(source.Services.ProjectManager());
 }
 public static bool IsWebSolution(this IProjectCommand source)
 {
     return(source.Solution() is WebProjectSolution);
 }
 public static void HandleBasicExceptions(this IProjectCommand source, Action action)
 {
     source.Services.ExceptionHandler(action, new Func <string>(source.CommandErrorMessage));
 }
 public static string FormatWithSolutionTypeSubtext(this IProjectCommand source, string template)
 {
     return(source.Services.FormatWithSolutionTypeSubtext(template));
 }
 public static void DisplayCommandFailedExceptionMessage(this IProjectCommand source, Exception exception)
 {
     source.DisplayCommandFailedMessage(exception.Message);
 }
 public static IDisposable SuspendWatchers(this IProjectCommand source)
 {
     return(new WatcherSuspender(source.Solution() as ISolutionManagement));
 }
 public static ISolution Solution(this IProjectCommand source)
 {
     return(source.Services.Solution());
 }