コード例 #1
0
        private void OnEnvDTEProjectRenamed(EnvDTEProject envDTEProject, string oldName)
        {
            if (!String.IsNullOrEmpty(oldName) && IsSolutionOpen)
            {
                EnsureNuGetAndEnvDTEProjectCache();

                if (EnvDTEProjectUtility.IsSupported(envDTEProject))
                {
                    RemoveEnvDTEProjectFromCache(oldName);
                    AddEnvDTEProjectToCache(envDTEProject);
                    NuGetProject nuGetProject;
                    _nuGetAndEnvDTEProjectCache.TryGetNuGetProject(envDTEProject.Name, out nuGetProject);

                    if (NuGetProjectRenamed != null)
                    {
                        NuGetProjectRenamed(this, new NuGetProjectEventArgs(nuGetProject));
                    }
                }
                else if (EnvDTEProjectUtility.IsSolutionFolder(envDTEProject))
                {
                    // In the case where a solution directory was changed, project FullNames are unchanged.
                    // We only need to invalidate the projects under the current tree so as to sync the CustomUniqueNames.
                    foreach (var item in EnvDTEProjectUtility.GetSupportedChildProjects(envDTEProject))
                    {
                        RemoveEnvDTEProjectFromCache(item.FullName);
                        AddEnvDTEProjectToCache(item);
                    }
                }
            }
        }
コード例 #2
0
        private void OnEnvDTEProjectRenamed(Project envDTEProject, string oldName)
        {
            NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                if (!string.IsNullOrEmpty(oldName) && await IsSolutionOpenAsync() && _solutionOpenedRaised)
                {
                    await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                    await EnsureNuGetAndVsProjectAdapterCacheAsync();

                    if (await EnvDTEProjectUtility.IsSupportedAsync(envDTEProject))
                    {
                        RemoveVsProjectAdapterFromCache(oldName);

                        var vsProjectAdapter = await _vsProjectAdapterProvider.CreateAdapterForFullyLoadedProjectAsync(envDTEProject);
                        await AddVsProjectAdapterToCacheAsync(vsProjectAdapter);

                        _projectSystemCache.TryGetNuGetProject(envDTEProject.Name, out var nuGetProject);

                        NuGetProjectRenamed?.Invoke(this, new NuGetProjectEventArgs(nuGetProject));

                        // VSSolutionManager susbscribes to this Event, in order to update the caption on the DocWindow Tab.
                        // This needs to fire after NugetProjectRenamed so that PackageManagerModel has been updated with
                        // the right project context.
                        AfterNuGetProjectRenamed?.Invoke(this, new NuGetProjectEventArgs(nuGetProject));
                    }
                    else if (EnvDTEProjectUtility.IsSolutionFolder(envDTEProject))
                    {
                        // In the case where a solution directory was changed, project FullNames are unchanged.
                        // We only need to invalidate the projects under the current tree so as to sync the CustomUniqueNames.
                        foreach (var item in await EnvDTEProjectUtility.GetSupportedChildProjectsAsync(envDTEProject))
                        {
                            RemoveVsProjectAdapterFromCache(item.FullName);

                            var vsProjectAdapter = await _vsProjectAdapterProvider.CreateAdapterForFullyLoadedProjectAsync(item);
                            if (await vsProjectAdapter.IsSupportedAsync())
                            {
                                await AddVsProjectAdapterToCacheAsync(vsProjectAdapter);
                            }
                        }
                    }
                }
            });
        }
コード例 #3
0
        private void OnEnvDTEProjectRenamed(EnvDTEProject envDTEProject, string oldName)
        {
            // This is a solution event. Should be on the UI thread
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!String.IsNullOrEmpty(oldName) && IsSolutionOpen && _solutionOpenedRaised)
            {
                EnsureNuGetAndEnvDTEProjectCache();

                if (EnvDTEProjectUtility.IsSupported(envDTEProject))
                {
                    RemoveEnvDTEProjectFromCache(oldName);
                    AddEnvDTEProjectToCache(envDTEProject);
                    NuGetProject nuGetProject;
                    _nuGetAndEnvDTEProjectCache.TryGetNuGetProject(envDTEProject.Name, out nuGetProject);

                    if (NuGetProjectRenamed != null)
                    {
                        NuGetProjectRenamed(this, new NuGetProjectEventArgs(nuGetProject));
                    }

                    // VSSolutionManager susbscribes to this Event, in order to update the caption on the DocWindow Tab.
                    // This needs to fire after NugetProjectRenamed so that PackageManagerModel has been updated with
                    // the right project context.
                    AfterNuGetProjectRenamed?.Invoke(this, new NuGetProjectEventArgs(nuGetProject));
                }
                else if (EnvDTEProjectUtility.IsSolutionFolder(envDTEProject))
                {
                    // In the case where a solution directory was changed, project FullNames are unchanged.
                    // We only need to invalidate the projects under the current tree so as to sync the CustomUniqueNames.
                    foreach (var item in EnvDTEProjectUtility.GetSupportedChildProjects(envDTEProject))
                    {
                        RemoveEnvDTEProjectFromCache(item.FullName);
                        AddEnvDTEProjectToCache(item);
                    }
                }
            }
        }