} // AddThirdParty private void Sort() { var libraryComparer = new DependencyLibraryNameComparer(); var thirdPartyComparer = new ThirdPartyDependencyNameComparer(); foreach (var item in _licenses) { var usedBy = item.Value; if (usedBy.Libraries.Count == 0) { usedBy.Libraries = null; } else { usedBy.Libraries.Sort(libraryComparer); } // if-else if (usedBy.ThirdParty.Count == 0) { usedBy.ThirdParty = null; } else { usedBy.ThirdParty.Sort(thirdPartyComparer); } // if-else } // foreach } // Sort
} // Expand private void AddIndirectLibraryDependencies() { // clear indirect dependencies _dataList.Where(data => data.Dependencies != null).ForEach(data => { data.Dependencies.Libraries?.RemoveAll(library => library.DependencyType == LicensedDependencyType.Indirect); data.Dependencies.ThirdParty?.RemoveAll(component => component.DependencyType == LicensedDependencyType.Indirect); }); // re-add indirect dependencies var comparer = new DependencyLibraryNameComparer(); var visited = new HashSet <string>(StringComparer.InvariantCulture); _dataList.ForEach(data => { AddIndirectLibraryDependencies(data, visited); data.Dependencies?.Libraries?.Sort(comparer); }); } // AddIndirectLibraryDependencies