public static string HierarchicalGraph <T>(IEnumerable <T> nodes, Delegates.GetChildren <T> childAccecor, Func <T, string> nameAccessor, Delegates.GetDependencyList <T> dataAccessor) => nodes.ToList().EncodeHierarchicalGraph(childAccecor, nameAccessor, dataAccessor);
public static IEnumerable <FlatEntry> FlattenGraph <T>(this IReadOnlyCollection <T> nodes, Delegates.GetChildren <T> childAccecor, Func <T, string> nameAccessor, Delegates.GetDependencyList <T> dataAccessor) { var names = nodes.GetFullLengthNodeNames(childAccecor, nameAccessor); var listToEncode = nodes.FlattenGraph(childAccecor, nameAccessor, dataAccessor, names); return(listToEncode); }
private static IEnumerable <FlatEntry> FlattenGraph <T>(this IEnumerable <T> nodes, Delegates.GetChildren <T> childAccecor, Func <T, string> nameAccessor, Delegates.GetDependencyList <T> dataAccessor, Dictionary <T, string> namesDict) { var entries = new List <FlatEntry>(); foreach (var node in nodes.OrderBy(nameAccessor)) { entries.Add(new FlatEntry { Path = namesDict[node], ChildData = dataAccessor(node).Select(n => namesDict[n]).ToList() }); entries.AddRange(childAccecor(node).FlattenGraph(childAccecor, nameAccessor, dataAccessor, namesDict)); } return(entries); }
public static string EncodeHierarchicalGraph <T>(this IReadOnlyCollection <T> nodes, Delegates.GetChildren <T> childAccecor, Func <T, string> nameAccessor, Delegates.GetDependencyList <T> dataAccessor) { var listToEncode = FlattenGraph(nodes, childAccecor, nameAccessor, dataAccessor); return(FlatListSerializer.EncodeList(listToEncode)); }