Esempio n. 1
0
        private void InternalExecute()
        {
            ISolutionManagement solutionManagement = this.Solution() as ISolutionManagement;

            if (solutionManagement == null)
            {
                return;
            }
            if (!this.SaveSolution(true))
            {
                return;
            }
            string      parentDirectory     = Microsoft.Expression.Framework.Documents.PathHelper.GetParentDirectory(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectory(solutionManagement.DocumentReference.Path));
            CultureInfo currentCulture      = CultureInfo.CurrentCulture;
            string      newNameCopyTemplate = StringTable.NewNameCopyTemplate;

            object[] fileNameWithoutExtension     = new object[] { Path.GetFileNameWithoutExtension(solutionManagement.DocumentReference.DisplayName) };
            string   availableFileOrDirectoryName = string.Format(currentCulture, newNameCopyTemplate, fileNameWithoutExtension);

            availableFileOrDirectoryName = Microsoft.Expression.Framework.Documents.PathHelper.GetAvailableFileOrDirectoryName(availableFileOrDirectoryName, null, parentDirectory, true);
            if (base.PromptUserForNewNameAndPath(ref parentDirectory, ref availableFileOrDirectoryName, false) == ProjectDialog.ProjectDialogResult.Ok)
            {
                using (IDisposable disposable = TemporaryCursor.SetWaitCursor())
                {
                    Directory.CreateDirectory(parentDirectory);
                    solutionManagement.SaveCopy(parentDirectory, availableFileOrDirectoryName);
                }
            }
        }
Esempio n. 2
0
 internal UpgradeWizard(ISolutionManagement solution, IEnumerable <IProjectStore> projectStoreContext, IProjectStore targetProjectStore, Action solutionUpgradedAction, IServiceProvider serviceProvider)
 {
     this.solution               = solution;
     this.serviceProvider        = serviceProvider;
     this.converter              = new SolutionConverter(solution, projectStoreContext, targetProjectStore, this.serviceProvider);
     this.solutionUpgradedAction = solutionUpgradedAction;
 }
Esempio n. 3
0
        private void ProjectManager_SolutionClosing(object sender, SolutionEventArgs e)
        {
            ISolutionManagement solution = e.Solution as ISolutionManagement;

            if (solution != null)
            {
                this.PersistProjectNodeState(solution);
            }
        }
Esempio n. 4
0
 public void Close()
 {
     foreach (Microsoft.Expression.Project.IProject key in this.projectCache.Keys)
     {
         this.OnProjectClosing(key, false);
     }
     this.projectCache.Clear();
     this.solution = null;
 }
Esempio n. 5
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;
                         }
                     }
                 }
             }
         }
     });
 }
        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. 7
0
 private void PersistProjectNodeState(ISolutionManagement solution)
 {
     foreach (ProjectNode projectNode in this.projectInsertion.Children.OfType <ProjectNode>())
     {
         if (projectNode.IsExpanded)
         {
             continue;
         }
         solution.SolutionSettingsManager.SetProjectProperty(projectNode.Project, ProjectPane.IsExpanded, false);
     }
 }
Esempio n. 8
0
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         IExecutable executable = this.SelectedProjectOrNull() as IExecutable;
         ISolutionManagement solutionManagement = this.Solution() as ISolutionManagement;
         if (executable != null && solutionManagement != null)
         {
             solutionManagement.StartupProject = executable;
         }
     });
 }
Esempio n. 9
0
        private void CleanupClosedSolution(ISolution solution)
        {
            ISolutionManagement solutionManagement = solution as ISolutionManagement;

            if (solutionManagement != null)
            {
                solutionManagement.AnyProjectOpened -= new EventHandler <NamedProjectEventArgs>(this.Solution_AnyProjectOpened);
                solutionManagement.AnyProjectClosed -= new EventHandler <NamedProjectEventArgs>(this.Solution_AnyProjectClosed);
            }
            this.ClearProjectCollection();
            this.ClearSolutionCollection();
        }
Esempio n. 10
0
        private Microsoft.Expression.Extensibility.Project.ISolution MakeSolutionForExtension()
        {
            ISolutionManagement currentSolution = this.projectManager.CurrentSolution as ISolutionManagement;

            if (currentSolution != null)
            {
                this.solution = new Microsoft.Expression.Extensibility.Project.Solution(currentSolution, this.projectManager);
                this.projectManager.SolutionClosing += new EventHandler <SolutionEventArgs>(this.projectManager_SolutionClosing);
                this.projectManager.ProjectClosing  += new EventHandler <ProjectEventArgs>(this.projectManager_ProjectClosing);
            }
            return(this.solution);
        }
Esempio n. 11
0
        public SolutionConverter(ISolutionManagement solution, IEnumerable <IProjectStore> contextProjectStores, IServiceProvider serviceProvider) : base(solution, serviceProvider)
        {
            this.contextProjectStores = contextProjectStores;
            List <IProjectConverter> projectConverters = new List <IProjectConverter>()
            {
                new SilverlightProjectConverter(solution, serviceProvider),
                new BlendSdkConverter(solution, serviceProvider),
                new FontEmbeddingSdkConverter(solution, serviceProvider),
                new WpfProjectConverter(solution, serviceProvider),
                new WebProjectConverter(solution, serviceProvider),
                new ToolsVersionConverter(solution, serviceProvider)
            };

            this.converters = projectConverters;
        }
Esempio n. 12
0
        private void EnsureServer(Microsoft.Expression.Framework.Documents.DocumentReference serverLocation)
        {
            if (this.serverHandle.HasValue && !this.webServerService.IsServerReachable(this.serverHandle.Value, WebsiteProject.CassiniTimeout))
            {
                this.webServerService.StopBrowsingSession(this.serverHandle.Value);
                this.serverHandle = null;
            }
            ISolutionManagement currentSolution = base.Services.ProjectManager().CurrentSolution as ISolutionManagement;

            if (!this.serverHandle.HasValue && currentSolution != null)
            {
                WebServerSettings webServerSetting = new WebServerSettings(serverLocation.Path);
                if (!this.cachedVswdPort.HasValue || !this.IsPortAvailable(this.cachedVswdPort.Value))
                {
                    object projectProperty = currentSolution.SolutionSettingsManager.GetProjectProperty(this, "Port");
                    if (projectProperty is int && this.IsPortAvailable((int)projectProperty))
                    {
                        webServerSetting.Port = (int)projectProperty;
                    }
                }
                else
                {
                    webServerSetting.Port = this.cachedVswdPort.Value;
                }
                this.serverHandle = new int?(this.webServerService.StartServer(webServerSetting));
            }
            if (this.serverHandle.HasValue && currentSolution != null)
            {
                string sessionAddress = this.webServerService.GetSessionAddress(this.serverHandle.Value);
                if (!string.IsNullOrEmpty(sessionAddress))
                {
                    Uri uri = new Uri(sessionAddress, UriKind.Absolute);
                    if (uri.Port >= 0)
                    {
                        currentSolution.SolutionSettingsManager.SetProjectProperty(this, "Port", uri.Port);
                    }
                }
            }
        }
Esempio n. 13
0
        private void ProjectManager_SolutionOpened(object sender, SolutionEventArgs e)
        {
            ProjectNode         projectNode;
            ISolutionManagement solution = e.Solution as ISolutionManagement;

            if (solution != null)
            {
                solution.AnyProjectOpened += new EventHandler <NamedProjectEventArgs>(this.Solution_AnyProjectOpened);
                solution.AnyProjectClosed += new EventHandler <NamedProjectEventArgs>(this.Solution_AnyProjectClosed);
            }
            this.projectInsertion = new SolutionNode(e.Solution, this);
            this.root.AddChild(this.projectInsertion);
            foreach (INamedProject allProject in ((ISolutionManagement)e.Solution).AllProjects)
            {
                IProject project = allProject as IProject;
                if (project == null)
                {
                    projectNode = new ProjectNode(allProject, this);
                }
                else
                {
                    projectNode = new KnownProjectNode(project, this);
                }
                if (solution != null)
                {
                    object projectProperty = solution.SolutionSettingsManager.GetProjectProperty(allProject, ProjectPane.IsExpanded);
                    if (projectProperty != null && projectProperty is bool)
                    {
                        projectNode.IsExpanded = (bool)projectProperty;
                    }
                    solution.SolutionSettingsManager.ClearProjectProperty(allProject, ProjectPane.IsExpanded);
                }
                this.projectInsertion.AddChild(projectNode);
            }
            this.EnableSearch = true;
            this.OnPropertyChanged("RootItem");
        }
Esempio n. 14
0
 public AggregatedConverter(ISolutionManagement solution, IServiceProvider serviceProvider) : base(solution, serviceProvider)
 {
 }
Esempio n. 15
0
 public WebProjectConverter(ISolutionManagement solution, IServiceProvider serviceProvider) : base(solution, serviceProvider)
 {
 }
Esempio n. 16
0
 public WatcherSuspender(ISolutionManagement solution)
 {
     this.solution = solution;
     solution.DeactivateWatchers();
 }
 public FontEmbeddingSdkConverter(ISolutionManagement solution, IServiceProvider serviceProvider) : base(solution, serviceProvider)
 {
 }
Esempio n. 18
0
 public ProjectConverterBase(ISolutionManagement solution, IServiceProvider serviceProvider)
 {
     this.solution = solution;
     this.Context  = new ProjectUpgradeContext(serviceProvider);
 }
Esempio n. 19
0
 public BlendSdkConverter(ISolutionManagement solution, IServiceProvider serviceProvider) : base(solution, serviceProvider)
 {
 }
Esempio n. 20
0
 public SolutionConverter(ISolutionManagement solution, IEnumerable <IProjectStore> contextProjectStores, IProjectStore targetStore, IServiceProvider serviceProvider) : this(solution, contextProjectStores, serviceProvider)
 {
     this.targetStore = targetStore;
 }
Esempio n. 21
0
 public ToolsVersionConverter(ISolutionManagement solution, IServiceProvider serviceProvider) : base(solution, serviceProvider)
 {
 }
Esempio n. 22
0
 internal Solution(ISolutionManagement solution, IProjectManager projectManager)
 {
     this.solution       = solution;
     this.projectManager = projectManager;
     this.projectCache   = new Dictionary <Microsoft.Expression.Project.IProject, Microsoft.Expression.Extensibility.Project.IProject>();
 }
Esempio n. 23
0
 internal ConversionTarget(ISolutionManagement solution)
 {
     this.Solution = solution;
 }
Esempio n. 24
0
        protected override void InternalExectute()
        {
            HashSet <IDocumentItem>       documentItems    = new HashSet <IDocumentItem>(new DocumentItemUrlComparer <IDocumentItem>());
            HashSet <IWebsiteProject>     websiteProjects  = new HashSet <IWebsiteProject>(new DocumentItemUrlComparer <IWebsiteProject>());
            List <IDocumentItem>          list             = null;
            List <IWebsiteProject>        list1            = null;
            IEnumerable <IWebsiteProject> websiteProjects1 = null;
            IDocumentItem documentItem = null;
            string        empty        = string.Empty;
            int           num          = 0;
            Func <IDocumentItem, IEnumerable <IDocumentItem> > array = null;

            if (this.targetSelection)
            {
                documentItem = this.Selection().SingleOrNull <IDocumentItem>();
            }
            else
            {
                documentItem = this.Solution();
            }
            if (documentItem == null)
            {
                return;
            }
            if (!this.SaveSolution(true))
            {
                return;
            }
            ISolutionManagement solutionManagement = (ISolutionManagement)this.Solution();

            if (documentItem != this.Solution())
            {
                array = (IDocumentItem IDocumentItem) => base.GetFileItemAndDescendants(documentItem).ToArray <IDocumentItem>();
                if (documentItem is IWebsiteProject)
                {
                    websiteProjects1 = new IWebsiteProject[] { (IWebsiteProject)documentItem };
                }
            }
            else
            {
                array            = (IDocumentItem IDocumentItem) => solutionManagement.AllProjects.SelectMany <INamedProject, IDocumentItem>((INamedProject project) => base.GetFileItemAndDescendants(project).AppendItem <IDocumentItem>(this.Solution()));
                websiteProjects1 = solutionManagement.AllProjects.OfType <IWebsiteProject>();
            }
            using (SolutionBase.DisableReloadPromptToken disableReloadPromptToken = new SolutionBase.DisableReloadPromptToken())
            {
                do
                {
                    if (websiteProjects1 == null)
                    {
                        list1 = null;
                    }
                    else
                    {
                        list1 = websiteProjects1.Except <IWebsiteProject>(websiteProjects, new DocumentItemUrlComparer <IWebsiteProject>()).ToList <IWebsiteProject>();
                        if (list1 != null && list1.Count <IWebsiteProject>() > 0)
                        {
                            base.SourceControlProvider.GetFiles((
                                                                    from item in list1
                                                                    select item.DocumentReference.Path).ToArray <string>(), ref empty, (SourceControlGetOption)((int)((num == 0 ? this.typeOfGet : this.typeOfGet & (SourceControlGetOption.All | SourceControlGetOption.Latest | SourceControlGetOption.Recursive))) | 256));
                            foreach (IWebsiteProject websiteProject in list1)
                            {
                                websiteProject.RefreshChildren(websiteProject, true);
                                websiteProjects.Add(websiteProject);
                            }
                            num = websiteProjects.Count <IWebsiteProject>() + documentItems.Count <IDocumentItem>();
                        }
                    }
                    list = array(documentItem).Except <IDocumentItem>(documentItems, new DocumentItemUrlComparer <IDocumentItem>()).ToList <IDocumentItem>();
                    if (list != null && list.Count <IDocumentItem>() > 0)
                    {
                        base.SourceControlProvider.GetFiles((
                                                                from item in list
                                                                select item.DocumentReference.Path).ToArray <string>(), ref empty, (num == 0 ? this.typeOfGet : this.typeOfGet & (SourceControlGetOption.All | SourceControlGetOption.Latest | SourceControlGetOption.Recursive)));
                        SourceControlStatusCache.UpdateStatus(list, base.SourceControlProvider);
                    }
                    documentItems.UnionWith(list);
                    num = websiteProjects.Count <IWebsiteProject>() + documentItems.Count <IDocumentItem>();
                    try
                    {
                        solutionManagement.ReactivateWatchers();
                    }
                    finally
                    {
                        solutionManagement.DeactivateWatchers();
                    }
                }while (list.Any <IDocumentItem>() || list1 != null && list1.Any <IWebsiteProject>());
            }
        }