/// <summary> /// Scans the solution for Spectrum Code Discovery projects /// </summary> public void CollectProjects() { HierarchyItems.Clear(); foreach (Project project in Root.Projects) { if (project.Kind == VsHierarchyTypes.SolutionFolder) { Traverse(project); } else if (project.Kind == VsHierarchyTypes.CodeDiscoveryProject) { _solutionService.GetProjectOfUniqueName(project.UniqueName, out var projectHierarchy); HierarchyItems.Add(new DiscoveryProject(project, projectHierarchy)); } } }
/// <summary> /// Traverses the specified project for ZX Spectrum projects /// </summary> /// <param name="projectToTraverse"></param> private void Traverse(Project projectToTraverse) { foreach (ProjectItem item in projectToTraverse.ProjectItems) { var project = item.SubProject; if (project == null) { continue; } if (project.Kind == VsHierarchyTypes.SolutionFolder) { Traverse(project); } else if (project.Kind == VsHierarchyTypes.CodeDiscoveryProject) { _solutionService.GetProjectOfUniqueName(project.UniqueName, out var projectHierarchy); HierarchyItems.Add(new DiscoveryProject(project, projectHierarchy)); } } }
/// <summary> /// Processes the specified item, and its sub items, provided it is a folder /// </summary> /// <param name="item">Item to process</param> public void ProcessProjectItem(ProjectItem item) { string extension; try { if (item.Properties.Item("Extension") == null) { return; } extension = (item.Properties.Item("Extension").Value?.ToString() ?? string.Empty).ToLower(); } catch { // --- The freshly deleted item cannot be found, and it results in exception. return; } if (extension == string.Empty && item.ProjectItems.Count > 0) { // --- This is a folder foreach (ProjectItem subItem in item.ProjectItems) { ProcessProjectItem(subItem); } } else if (string.Compare(extension, VsHierarchyTypes.DISANN_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new AnnotationProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.ROM_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new SpectrumRomProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.TZX_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new TzxProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.TAP_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new TapProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.Z80_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new Z80CodeProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.ZX_BASIC_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new ZxBasicProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.TEST_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new Z80TestProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.SP_CONF_ITEM, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new SpectrumProjectConfigItem(item)); } else { HierarchyItems.Add(new UnusedProjectItem(item)); } }
/// <summary> /// Processes the specified item, and its sub items, provided it is a folder /// </summary> /// <param name="item">Item to process</param> public void ProcessProjectItem(ProjectItem item) { string extension; try { if (item.Properties.Item("Extension") == null) return; extension = (item.Properties.Item("Extension").Value?.ToString() ?? string.Empty).ToLower(); } catch { // --- The freshly deleted item cannot be found, and it results in exception. return; } if (extension == string.Empty && item.ProjectItems.Count > 0) { // --- This is a folder foreach (ProjectItem subItem in item.ProjectItems) { ProcessProjectItem(subItem); } } else if (string.Compare(extension, VsHierarchyTypes.DisannItem, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new AnnotationProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.RomItem, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new RomProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.TzxItem, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new TzxProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.TapItem, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new TapProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.Z80Item, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new Z80CodeProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.TestItem, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new Z80TestProjectItem(item)); } else if (string.Compare(extension, VsHierarchyTypes.SpConfItem, StringComparison.InvariantCultureIgnoreCase) == 0) { HierarchyItems.Add(new SpConfProjectItem(item)); } else { HierarchyItems.Add(new UnusedProjectItem(item)); } }