public void AddNewChild(ITestingItemReport root, string[] parentsName, TestingModuleReport module) { // folder ITestingItemReport currentItem = root; for (int fi = 1; fi < parentsName.Length; fi++) { string currentName = parentsName[fi]; var child = CheckListItemContain(currentItem.Children, currentName); if (child == null) { child = new TestingFolderReport(currentName); if (currentItem.Children == null) { currentItem.Children = new ObservableCollection <ITestingItemReport>(); } currentItem.Children.Add(child); } currentItem = child; } // module if (currentItem.Children == null) { currentItem.Children = new ObservableCollection <ITestingItemReport>(); } currentItem.Children.Add(module); }
public void Convert() { listRoots = new ObservableCollection <ITestingItemReport>(); foreach (TestingModuleReport module in listTestModules) { string relativePath = module.RelativeFilePath; string[] strs = relativePath.Split('\\'); // if FeatureX\FeatureX_1 if (strs.Length > 1) { string[] parentsName = new string[strs.Length - 1]; Array.Copy(strs, 0, parentsName, 0, strs.Length - 1); var root = CheckListItemContain(listRoots, parentsName[0]); if (root == null) { root = new TestingFolderReport(parentsName[0]); listRoots.Add(root); } AddNewChild(root, parentsName, module); } // if FeatureX_1 else { listRoots.Add(module); } } }