Exemple #1
0
        public override void Execute()
        {
            if (!this.IsEnabled)
            {
                return;
            }
            this.commandService.Execute("Application_SaveAll", CommandInvocationSource.Internally);
            EditVisualStudioCommand.VisualStudioAsyncOpen visualStudioAsyncOpen = new EditVisualStudioCommand.VisualStudioAsyncOpen(this.messageDisplayService);
            Version version      = new Version(0, 0);
            string  solutionName = (string)null;

            if (this.projectManager.CurrentSolution != null)
            {
                if (this.projectManager.CurrentSolution.GetType().IsDefined(typeof(VisualStudioSolutionAttribute), true))
                {
                    solutionName = this.projectManager.CurrentSolution.DocumentReference.Path;
                }
                version = this.projectManager.CurrentSolution.VersionNumber;
            }
            foreach (IDocumentItem documentItem in this.projectManager.ItemSelectionSet.Selection)
            {
                string        projectItemName = (string)null;
                SolutionModel solutionModel;
                if (documentItem is INamedProject)
                {
                    solutionModel = this.solutionModelProvider.FromProject(solutionName, documentItem.DocumentReference.Path, VSLaunchFlags.DoNotClose | VSLaunchFlags.ShowUI, version);
                }
                else if (documentItem.GetType().IsDefined(typeof(VisualStudioSolutionAttribute), true))
                {
                    solutionModel = this.solutionModelProvider.FromSolution(documentItem.DocumentReference.Path, VSLaunchFlags.DoNotClose | VSLaunchFlags.ShowUI, version);
                }
                else
                {
                    IProjectItem projectItem = documentItem as IProjectItem;
                    if (projectItem != null && projectItem.DocumentType.AllowVisualStudioEdit)
                    {
                        solutionModel   = this.solutionModelProvider.FromProject(solutionName, projectItem.Project.DocumentReference.Path, VSLaunchFlags.DoNotClose | VSLaunchFlags.ShowUI, version);
                        projectItemName = documentItem.DocumentReference.DisplayName;
                    }
                    else
                    {
                        continue;
                    }
                }
                visualStudioAsyncOpen.Add(solutionModel, projectItemName);
            }
            visualStudioAsyncOpen.Start();
        }
Exemple #2
0
 private void Open()
 {
     foreach (EditVisualStudioCommand.VisualStudioAsyncOpenData studioAsyncOpenData in this.itemsToOpen)
     {
         try
         {
             using (new MessageFilter())
                 studioAsyncOpenData.SolutionModel.OpenVisualStudio(studioAsyncOpenData.ProjectItemName);
         }
         catch (Exception ex)
         {
             EditVisualStudioCommand.VisualStudioAsyncOpen visualStudioAsyncOpen = this;
             UIThreadDispatcher.Instance.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() => visualStudioAsyncOpen.displayException(ex)));
         }
         finally
         {
             EditVisualStudioCommand.VisualStudioAsyncOpen.opening = false;
         }
     }
 }