public void InitializeSolution(Solution solution) { ReadNextLine(); solution.Version = GetSolutionVersion(_currentLine); Match match; SolutionRootNodeType nodeType = SolutionRootNodeType.Unknown; ReadNextLine(); while ((nodeType = GetCurrentRootNodeType(out match)) != SolutionRootNodeType.Unknown) { switch (nodeType) { case SolutionRootNodeType.Project: solution.Nodes.Add(ReadProjectEntry(solution, match)); break; case SolutionRootNodeType.Property: break; case SolutionRootNodeType.Global: ReadGlobalSection(solution); break; } ReadNextLine(); } FixNestedProjects(solution); }
public void WriteSolution(Solution solution) { WriteSolutionHeader(solution.Version); foreach (var node in solution.Nodes) { WriteNode(node); } _writer.WriteLine("Global"); foreach (var section in solution.GlobalSections) { WriteSection(section); } _writer.WriteLine("EndGlobal"); }
private void FixNestedProjects(Solution solution) { var nestedProjectsSection = solution.GlobalSections.FirstOrDefault(x => x.Name == "NestedProjects"); if (nestedProjectsSection != null) { foreach (var item in nestedProjectsSection) { Guid projectGuid; Guid folderGuid; if (Guid.TryParse(item.Key, out projectGuid) && Guid.TryParse(item.Value, out folderGuid)) { var project = solution.GetSolutionNode(x => x.ObjectGuid == projectGuid); var folder = (SolutionFolder)solution.GetSolutionNode(x => x.ObjectGuid == folderGuid); if (project != null && folder != null) { project.Parent.Nodes.Remove(project); folder.Nodes.Add(project); } } } } }
private SolutionFolder ReadProjectEntry(Solution parent, Match match) { string path = match.Groups["HintPath"].Value; SolutionFolder entry; Guid typeID = Guid.Parse(match.Groups["TypeGuid"].Value); if (typeID == SolutionFolder.SolutionFolderGuid) { entry = new SolutionFolder(); } else { entry = new ProjectEntry(); } entry.TypeGuid = typeID; entry.Name = match.Groups["Name"].Value; entry.FilePath = new FilePath(parent.FilePath.ParentDirectory.FullPath, match.Groups["HintPath"].Value); entry.ObjectGuid = Guid.Parse(match.Groups["ProjectGuid"].Value); ReadNextLine(); Match sectionMatch; while (IsAtSection(out sectionMatch)) { entry.Sections.Add(ReadSection(sectionMatch)); ReadNextLine(); } if (_currentLine != "EndProject") ThrowSyntaxError("Expected \"EndProject\" keyword."); return entry; }
private void ReadGlobalSection(Solution parent) { Match match; ReadNextLine(); while (IsAtSection(out match)) { var section = ReadSection(match); if (section.SectionType != "Global") ThrowSyntaxError("Expected \"GlobalSection\" keyword."); parent.GlobalSections.Add(section); ReadNextLine(); } if (_currentLine != "EndGlobal") ThrowSyntaxError("Expected \"EndGlobal\" keyword."); }
public SolutionEventArgs(Solution file) { TargetSolution = file; }
private void _extensionHost_SolutionUnload(object sender, SolutionEventArgs e) { _solution = null; mainTreeView.Nodes.Clear(); }
private void _extensionHost_SolutionLoad(object sender, SolutionEventArgs e) { _solution = _extensionHost.CurrentSolution; _solution.Settings.StartupProjects.InsertedItem += StartupProjects_Changed; _solution.Settings.StartupProjects.RemovedItem += StartupProjects_Changed; contextMenuStrip1.Renderer = _extensionHost.ControlManager.MenuRenderer; mainTreeView.Nodes.Add(new SolutionNode(_solution, _iconProvider)); }
/// <summary> /// Opens an existing solution file and parses out the sub projects. /// </summary> /// <param name = "solutionFile">The file path to the solution file.</param> public static Solution OpenSolution(string solutionFile) { using (var reader = new StreamReader(solutionFile)) { using (var solutionReader = new SolutionReader(reader)) { var solution = new Solution(); solution.FilePath = new FilePath(solutionFile); solution.Name = solution.FilePath.FileName; solutionReader.InitializeSolution(solution); solution.InitializeEventHandlers(); var settingsPath = solution.FilePath.ChangeExtension(".litesettings").FullPath; if (File.Exists(settingsPath)) { try { var settings = SolutionSettings.ReadSettings(settingsPath); solution.Settings = settings; } catch { // TODO: notify user } } return solution; } } }
public SolutionNode(Solution solution, IconProvider iconProvider) : base(solution, iconProvider) { Solution = solution; }