コード例 #1
0
        public void Initialize(IEnumerable <EnvDTEProject> projects, VSNuGetProjectFactory factory)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (projects.Any())
            {
                foreach (EnvDTEProject project in projects)
                {
                    try
                    {
                        // If a single project fails this method throws and the rest of the projects will never load
                        AddProject(project, factory);
                    }
                    catch (Exception ex)
                    {
                        // ignore failed projects
                        ActivityLog.LogWarning(ExceptionHelper.LogEntrySource,
                                               "The project " + project.Name + " failed to initialize as a nuget project");

                        ExceptionHelper.WriteToActivityLog(ex);
                    }
                }

                // Consider that the cache is initialized, only, when there are any projects to add
                IsInitialized = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Add a project to the cache.
        /// </summary>
        /// <param name="project">project to add to the cache.</param>
        /// <returns>The project name of the added project.</returns>
        public EnvDTEProjectName AddProject(EnvDTEProject project, VSNuGetProjectFactory factory)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // Create the nuget project first, if this throws we bail out, and not change the cache
            var nuGetProject = factory.CreateNuGetProject(project);

            // First create a project name from the project
            var EnvDTEProjectName = new EnvDTEProjectName(project);

            // Do nothing if we already have an entry
            if (_envDTEProjectCache.ContainsKey(EnvDTEProjectName))
            {
                return(EnvDTEProjectName);
            }

            AddShortName(EnvDTEProjectName);

            _projectNamesCache[EnvDTEProjectName.CustomUniqueName] = EnvDTEProjectName;
            _projectNamesCache[EnvDTEProjectName.UniqueName]       = EnvDTEProjectName;
            _projectNamesCache[EnvDTEProjectName.FullName]         = EnvDTEProjectName;

            // Add the entry mapping project name to the actual project
            _envDTEProjectCache[EnvDTEProjectName] = project;

            _nuGetProjectCache[EnvDTEProjectName] = nuGetProject;

            return(EnvDTEProjectName);
        }
コード例 #3
0
        private VSNuGetProjectFactory GetProjectFactory()
        {
            var settings = ServiceLocator.GetInstance <ISettings>();

            // We are doing this to avoid a loop at initialization. We probably want to remove this dependency altogether.
            var factory = new VSNuGetProjectFactory(() => PackagesFolderPathUtility.GetPackagesFolderPath(this, settings));

            return(factory);
        }
コード例 #4
0
        public void Initialize(IEnumerable <Project> projects, VSNuGetProjectFactory factory)
        {
            foreach (EnvDTEProject project in projects)
            {
                AddProject(project, factory);
            }

            IsInitialized = true;
        }
コード例 #5
0
        /// <summary>
        /// Add a project to the cache.
        /// </summary>
        /// <param name="project">project to add to the cache.</param>
        /// <returns>The project name of the added project.</returns>
        public EnvDTEProjectName AddProject(EnvDTEProject project, VSNuGetProjectFactory factory)
        {
            // First create a project name from the project
            var EnvDTEProjectName = new EnvDTEProjectName(project);

            // Do nothing if we already have an entry
            if (_envDTEProjectCache.ContainsKey(EnvDTEProjectName))
            {
                return(EnvDTEProjectName);
            }

            AddShortName(EnvDTEProjectName);

            _projectNamesCache[EnvDTEProjectName.CustomUniqueName] = EnvDTEProjectName;
            _projectNamesCache[EnvDTEProjectName.UniqueName]       = EnvDTEProjectName;
            _projectNamesCache[EnvDTEProjectName.FullName]         = EnvDTEProjectName;

            // Add the entry mapping project name to the actual project
            _envDTEProjectCache[EnvDTEProjectName] = project;
            _nuGetProjectCache[EnvDTEProjectName]  = factory.CreateNuGetProject(project);

            return(EnvDTEProjectName);
        }
コード例 #6
0
        public static bool SupportsINuGetProjectSystem(EnvDTEProject envDTEProject)
        {
            var projectKProject = VSNuGetProjectFactory.GetProjectKProject(envDTEProject);

            return(projectKProject != null);
        }