Esempio n. 1
0
        public void AddProjectToSolutionFolder(IDotNetProjectInstance project, IDotNetSolutionFolder solutionFolder)
        {
            if (project.Id == solutionFolder.Id)
            {
                throw new InvalidOperationException("A solution folder cannot be self-referencing.");
            }

            RemoveProjectFromSolutionFolder(project);
            SlnFile.GetSolutionFolderSection().Properties[project.Id] = solutionFolder.Id;
        }
Esempio n. 2
0
        public IEnumerable <IDotNetProjectInstance> GetProjectsUnderSolutionFolder(IDotNetSolutionFolder solutionFolder)
        {
            var solutionFolderSection = SlnFile.GetSolutionFolderSection();
            var parentId = solutionFolder.Id;
            var childIds = solutionFolderSection.Properties.Where(p => p.Value == parentId)
                           .Select(p => p.Key)
                           .ToImmutableHashSet();

            return(AllProjects.Where(p => childIds.Contains(p.Id)));
        }
Esempio n. 3
0
        /// <summary>
        /// Processes the solution file to extract the collection of solution folders and their IDs.
        /// </summary>
        /// <param name="slnFile">The solution file to examine.</param>
        /// <returns>A dictionary of all of the solution folders present in the solution mapped to their IDs.</returns>
        /// <example>"SomeFolder\SomeSubFolder" => "{SOME-GUID}"</example>
        public static IDictionary <string, string> GetSolutionFolderPaths(this SlnFile slnFile)
        {
            var nestedProjects = slnFile.GetSolutionFolderSection();

            if (nestedProjects == null)
            {
                return(new Dictionary <string, string>());
            }

            return(slnFile.GetSolutionFolderPaths(nestedProjects.Properties));
        }
Esempio n. 4
0
        public IDotNetSolutionFolder FindParentSolutionFolder(IDotNetProjectInstance projectInstance)
        {
            if (SlnFile.GetSolutionFolderSection().Properties.TryGetValue(projectInstance.Id, out var parentProjectId))
            {
                var parentProject = FindProjectById(parentProjectId);
                if (parentProject is IDotNetSolutionFolder)
                {
                    return(parentProject as IDotNetSolutionFolder);
                }
            }

            return(null);
        }
Esempio n. 5
0
 public void RemoveProjectFromSolutionFolder(IDotNetProjectInstance project)
 {
     SlnFile.GetSolutionFolderSection().Properties.Remove(project.Id);
 }