Exemple #1
0
        /// <summary>
        /// Adds the specified projects.
        /// </summary>
        /// <param name="projects">An <see cref="IEnumerable{SlnProject}"/> containing projects to add to the solution.</param>
        public void AddProjects(IEnumerable <SlnProject> projects)
        {
            _projects.AddRange(projects.Select(project =>
            {
                if (project != null && ExistingProjectGuids != null && ExistingProjectGuids.TryGetValue(project.FullPath, out Guid projectGuid))
                {
                    project.ProjectGuid = projectGuid;
                }

                return(project);
            }));
        }
Exemple #2
0
        /// <summary>
        /// Adds the specified projects to the solution file.
        /// </summary>
        /// <param name="projects">An <see cref="IEnumerable{T}" /> of projects to add.</param>
        /// <param name="customProjectTypeGuids">An <see cref="IReadOnlyDictionary{TKey,TValue}" /> containing any custom project type GUIDs to use.</param>
        /// <param name="mainProjectFullPath">Optional full path to the main project.</param>
        public void AddProjects(IEnumerable <Project> projects, IReadOnlyDictionary <string, Guid> customProjectTypeGuids, string mainProjectFullPath = null)
        {
            _projects.AddRange(
                projects
                .Distinct(new EqualityComparer <Project>((x, y) => string.Equals(x.FullPath, y.FullPath, StringComparison.OrdinalIgnoreCase), i => i.FullPath.GetHashCode()))
                .Select(i =>
            {
                SlnProject project = SlnProject.FromProject(i, customProjectTypeGuids, string.Equals(i.FullPath, mainProjectFullPath, StringComparison.OrdinalIgnoreCase));

                if (project != null && ExistingProjectGuids != null && ExistingProjectGuids.TryGetValue(project.FullPath, out Guid projectGuid))
                {
                    project.ProjectGuid = projectGuid;
                }

                return(project);
            })
                .Where(i => i != null));
        }