private static bool IsNetFrameworkProject(SolutionItem solutionItem) { switch (SolutionItemTypes.GetType(solutionItem.ProjectType)) { case SolutionItemType.CSharp: case SolutionItemType.VbNet: case SolutionItemType.JSharp: return true; } return false; }
/// <summary> /// Factory method that creates readers. /// </summary> /// <param name="solutionItem"> /// Solution item for which reader must be created. /// </param> /// <returns> /// Project reader object. /// </returns> public static ProjectReader CreateProjectReader(SolutionItem solutionItem) { SolutionItemType itemType = SolutionItemTypes.GetType(solutionItem.ProjectType); switch (itemType) { case SolutionItemType.CSharp: case SolutionItemType.VbNet: case SolutionItemType.JSharp: return new NetProjectReader(solutionItem.ProjectFileFullName); case SolutionItemType.Cpp: return new VcxProjectReader(solutionItem.ProjectFileFullName); } return null; }
private void ExtractItems(string content) { List<ISolutionItem> items = new List<ISolutionItem>(); Regex regex = new Regex(@"Project.*\s*EndProject", RegexOptions.Multiline); var matches = regex.Matches(content); foreach(Match m in matches) { string projectInfo = TrimProjectTags(m.Value); string[] projectSections = projectInfo.Split(new char[] { '=', ',' }); Debug.Assert(projectSections.Length == 4); Guid itemTypeGuid = new Guid(ExtractGuid(projectSections[0])); string itemName = ExtractQuotedString(projectSections[1]); string projectFilename = ExtractQuotedString(projectSections[2]); Guid itemGuid = new Guid(ExtractGuid(projectSections[3])); ISolutionItem item = new SolutionItem(itemName, itemTypeGuid, projectFilename, itemGuid); items.Add(item); } m_items = items.ToArray(); }
/// <summary> /// Extracts solution items from solution file content. /// </summary> /// <param name="reader"> /// <c>TextReader</c> to read the content of solution file. /// </param> /// <param name="solutionFolder"> /// Absolute path to the solution root. /// </param> /// <returns> /// List of all items in the solution. /// </returns> private IEnumerable<SolutionItem> ExtractItems(TextReader reader, string solutionFolder) { List<SolutionItem> items = new List<SolutionItem>(); string content = reader.ReadToEnd(); Regex regex = new Regex(@"Project.*\s*EndProject", RegexOptions.Multiline); var matches = regex.Matches(content); foreach (Match m in matches) { string projectInfo = TrimProjectTags(m.Value); string[] projectSections = projectInfo.Split(new char[] { '=', ',' }); Debug.Assert(projectSections.Length == 4); Guid itemTypeGuid = new Guid(ExtractGuid(projectSections[0])); string itemName = ExtractQuotedString(projectSections[1]); string projectFilename = ExtractQuotedString(projectSections[2]); Guid itemGuid = new Guid(ExtractGuid(projectSections[3])); SolutionItem item = new SolutionItem(itemName, itemTypeGuid, projectFilename, itemGuid, solutionFolder); items.Add(item); } return items; }
public static VersionFileSelector CreateSelector(SolutionItem solutionItem) { if (IsNetFrameworkProject(solutionItem)) return new AssemblyInfoVersionFileSelector(); return new NoVersionFileSelector(); }