} // AddIndirectLibraryDependencies private void AddIndirectThirdParty(LicensingData data) { if ((data.Dependencies == null) || !data.Dependencies.LibrariesSpecified) { return; } var added = new HashSet <string>(); data.Dependencies.ThirdParty?.ForEach(component => added.Add(component.Name)); var q = from dependency in data.Dependencies.Libraries let library = _libraries[dependency.Name] where (library.Dependencies != null) && library.Dependencies.ThirdPartySpecified from thirdParty in library.Dependencies.ThirdParty select thirdParty.Clone(); q.ForEach(dependency => { if (added.Contains(dependency.Name)) { return; } dependency.DependencyType = LicensedDependencyType.Indirect; data.Dependencies.ThirdParty ??= new List <ThirdPartyDependency>(); data.Dependencies.ThirdParty.Add(dependency); added.Add(dependency.Name); }); data.Dependencies.ThirdParty?.Sort(new ThirdPartyDependencyNameComparer()); } // AddIndirectThirdParty
public TreeNode DataToTree(string name, LicensingData data) { var root = new TreeNode(name, _images.LicensingData, _images.LicensingData) { Tag = data }; var node = LicensedItemToNode(data.Licensed); root.Nodes.Add(node); AddDependenciesNodes(root, data.Dependencies); AddLicensesNodes(root, data.Licenses); root.Expand(); return(root); } // DataToTree
} // AddIndirectThirdParty private void AddIndirectLibraryDependencies(LicensingData data, HashSet <string> visited) { if (data.Dependencies?.Libraries == null) { return; } // avoid circular references if (visited.Contains(data.Licensed.Name)) { return; } visited.Add(data.Licensed.Name); // add indirect library dependencies var q = from dependency in data.Dependencies.Libraries select _libraries[dependency.Name]; q.ForEach(AddIndirectLibraryDependencies, visited); // create hashset to avoid adding duplicated dependencies var added = new HashSet <string>(); data.Dependencies.Libraries.ForEach(lib => added.Add(lib.Name ?? throw new ArgumentException())); var libraries = (from dependency in data.Dependencies.Libraries select _libraries[dependency.Name]).ToArray(); var dependencies = from library in libraries where library.Dependencies?.Libraries != null from dependency in library.Dependencies.Libraries select dependency.Clone(); dependencies.ForEach(dependency => { if (added.Contains(dependency.Name)) { return; } var library = dependency.Clone(); library.DependencyType = LicensedDependencyType.Indirect; data.Dependencies.Libraries.Add(library); added.Add(dependency.Name); }); } // AddIndirectLibraryDependencies
} // ExpandDependencies public static LicensingUsage GetUsage(this LicensingData data) { return(new GetLicensingUsage(data).Get()); } // GetUsage
public GetLicensingUsage(LicensingData data) { _data = data; } // constructor