private static Project GetSolutionItemByName( _Solution solution, string itemName) { return(solution.Projects .Cast <object>() .OfType <Project>() .FirstOrDefault(a => string.Equals( a.Name, itemName, StringComparison.CurrentCultureIgnoreCase))); }
private static string GetTextDocumentPathInSolution(_Solution solution, TextDocument textDocument) { var textDocumentFullName = ((DTE2)textDocument.DTE).ActiveDocument.FullName; var solutionPath = new FileInfo((solution).FullName).DirectoryName; if (solutionPath == null) { return(textDocumentFullName); } var textDocumentPathInSolution = textDocumentFullName.Replace(solutionPath, string.Empty); return(textDocumentPathInSolution.StartsWith(@"\") ? textDocumentPathInSolution.Substring(1) : textDocumentPathInSolution); }
/// <summary> Gets the list of projects from the solution</summary> /// <param name="solution">The Solution object</param> /// <returns>List of projects</returns> private static IEnumerable <Project> GetProjects(_Solution solution) { // Locals var projects = solution.Projects; var list = new List <Project>(); var item = projects.GetEnumerator(); try { // Iterate while (item.MoveNext()) { var project = (Project)item.Current; if (project == null) { continue; } // only add project folder if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder) { list.AddRange(GetSolutionFolderProjects(project)); } else { list.Add(project); } } } catch { // No action as it will be reviewed by caller } return(list); }
public FinderDefinitionForm(_Solution solution) { InitializeComponent(); try { foreach (Project project in solution.Projects) { var pattern = new Regex(@"^(?<company>\w+)\.(?<module>\w+)\.(?<projectName>\w+)"); var match = pattern.Match(project.Name); var module = match.Groups["module"].ToString(); var projectName = match.Groups["projectName"].ToString(); if (projectName == "Web") { projectLookup.Add(module, project); } } } catch { //TODO log something??? } }
/// <summary> Determine if the Solution is valid </summary> /// <param name="solution">Solution </param> /// <returns>true if valid otherwise false</returns> private static bool ValidSolution(_Solution solution) { // Validate solution return(solution != null); }