Exemplo n.º 1
0
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         using (ProjectUpgradeLogger projectUpgradeLogger = new ProjectUpgradeLogger())
         {
             IProject project = this.SelectedProjectOrNull();
             ISolutionManagement solutionManagement = this.Solution() as ISolutionManagement;
             if (base.Services.PromptUserYesNo(StringTable.UpgradeProjectWarning))
             {
                 if (this.SaveSolution(true))
                 {
                     if (this.SaveSolution(true))
                     {
                         DocumentReference documentReference = project.DocumentReference;
                         solutionManagement.CloseProject(project);
                         IProjectStore projectStore = null;
                         try
                         {
                             projectStore = ProjectStoreHelper.CreateProjectStore(documentReference, base.Services, ProjectStoreHelper.DefaultProjectCreationChain);
                             using (IDisposable disposable = this.SuspendWatchers())
                             {
                                 if (this.converter.Convert(new ConversionTarget(projectStore), this.sourceType, this.targetType))
                                 {
                                     using (IDisposable disposable1 = projectUpgradeLogger.SuspendLogging())
                                     {
                                         projectStore.Dispose();
                                         projectStore = ProjectStoreHelper.CreateProjectStore(documentReference, base.Services, ProjectStoreHelper.DefaultProjectCreationChain);
                                         if (solutionManagement.AddProject(projectStore) == null)
                                         {
                                             projectStore.Dispose();
                                         }
                                     }
                                     solutionManagement.OpenInitialViews();
                                 }
                                 else
                                 {
                                     projectStore.Dispose();
                                     return;
                                 }
                             }
                             UpgradeWizard.SaveLogAndPromptUser(projectUpgradeLogger, base.Services, solutionManagement.DocumentReference.Path, true);
                         }
                         catch
                         {
                             if (projectStore != null)
                             {
                                 projectStore.Dispose();
                             }
                             UpgradeWizard.SaveLogAndPromptUser(projectUpgradeLogger, base.Services, solutionManagement.DocumentReference.Path, false);
                             throw;
                         }
                     }
                 }
             }
         }
     });
 }
Exemplo n.º 2
0
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         string str = base.SelectProject(this.DisplayName);
         if (!string.IsNullOrEmpty(str))
         {
             IProjectStore projectStore = ProjectStoreHelper.CreateProjectStore(DocumentReference.Create(str), base.Services, ProjectStoreHelper.ResilientProjectCreationChain);
             if (projectStore == null)
             {
                 return;
             }
             UpgradeWizard upgradeWizard = new UpgradeWizard(this.Solution() as ISolutionManagement,
                                                             from project in this.Solution().Projects.OfType <ProjectBase>()
                                                             select project.ProjectStore, projectStore, null, base.Services);
             try
             {
                 if (!upgradeWizard.Upgrade())
                 {
                     return;
                 }
             }
             finally
             {
                 projectStore.Dispose();
                 projectStore = null;
             }
             projectStore = ProjectStoreHelper.CreateProjectStore(DocumentReference.Create(str), base.Services, ProjectStoreHelper.DefaultProjectCreationChain);
             if (projectStore == null)
             {
                 return;
             }
             INamedProject namedProject = null;
             try
             {
                 namedProject = this.ProjectManager().AddProject(projectStore);
                 if (namedProject != null)
                 {
                     base.UpdateSourceControl(EnumerableExtensions.AsEnumerable <INamedProject>(namedProject));
                     base.ActivateProjectPane();
                 }
             }
             finally
             {
                 if (namedProject == null && projectStore != null)
                 {
                     projectStore.Dispose();
                     projectStore = null;
                 }
             }
         }
     });
 }