public void RebuildFor(string path, bool remove) { if (!_forward.TryGetValue(path, out var fwMeta)) { fwMeta = new FwMeta(); _forward.Add(path, fwMeta); } else if (remove) { foreach (var dependency in fwMeta.Dependencies) { if (!Backward.TryGetValue(dependency, out var backDep)) { continue; } backDep.Lookup.Remove(path); } fwMeta.Dependencies = null; } var dependencies = _Dependencies(path); fwMeta.Dependencies = new HashSet <string>(dependencies); foreach (var backPath in dependencies) { if (!Backward.TryGetValue(backPath, out var bwMeta)) { bwMeta = new BwMeta { Lookup = new HashSet <string>() }; Backward.Add(backPath, bwMeta); } else if (remove) { bwMeta.Lookup.Remove(path); } bwMeta.Lookup.Add(path); } if (!remove) { UpdateFoldersWithQtyByPath(path); } }
void _FillFwAndBacklinks(string path) { var dependencies = _Dependencies(path); var hs = new FwMeta { Dependencies = new HashSet <string>(dependencies) }; _forward.Add(path, hs); foreach (var backPath in dependencies) { if (!Backward.TryGetValue(backPath, out var val)) { val = new BwMeta(); val.Lookup = new HashSet <string>(); Backward.Add(backPath, val); } val.Lookup.Add(path); } }