public void Merge(ICollection <RoutingMapLink> links, IAddress source) { var oldLinks = Links.ToList(); var linksToAdd = links.Where(link => !link.Contains(OwnAddress) && ((link.Contains(source) && link.Connected != Links.FirstOrDefault(l => Equals(l, link)).Connected) || link.Version > Links.FirstOrDefault(l => Equals(l, link)).Version)).ToList(); if (linksToAdd.Count > 0) { Version++; } foreach (var link in linksToAdd) { Links.Remove(link); } Links.AddRange(linksToAdd); foreach (var link in links.Where(l => !l.Connected)) { if (!Links.Contains(link)) { Links.Add(link); } } //Console.WriteLine("[{0}] MERGE {1} with {2} from {3} => {4}", OwnAddress, // oldLinks.ToDOT(longNames: config.LongNames), links.ToDOT(longNames: config.LongNames), source, Links.ToDOT(longNames: config.LongNames)); }
/// <summary> /// parse page contents, find all links /// if not found before: push on stack, add to list /// </summary> /// <param name="Page">page html contents</param> private void FindLinks(string Page) { HtmlDocument Doc = new HtmlDocument(); Doc.LoadHtml(Page); if (Doc.ParseErrors != null && Doc.ParseErrors.Count() > 0 && Doc.DeclaredEncoding != null && Doc.DeclaredEncoding.Equals(System.Text.Encoding.UTF8)) { foreach (var Error in Doc.ParseErrors) { Debug.WriteLine(Error.ToString()); } } if (Doc.DocumentNode != null && Doc.DeclaredEncoding != null && Doc.DeclaredEncoding.Equals(System.Text.Encoding.UTF8)) { foreach (var Link in Doc.DocumentNode.Descendants("a") .Select(a => a.GetAttributeValue("href", null)) .Where(u => !string.IsNullOrEmpty(u) && !IgnoreList.Any(s => u.Contains(s)) && !Links.Contains((u.StartsWith("/")) ? Domain + u : u) && (u.StartsWith("/") || u.StartsWith(Domain)))) { string Temp = (Link.StartsWith("/")) ? Domain + Link : Link; Links.Add(Temp); Crawler.Push(Temp); } } }
public void AddLink(Zone zone) { if (!Links.Contains(zone)) { Links.Add(zone); zone.Links.Add(this); } }
public bool Remove(Link link) { if (Links.Contains(link)) { return(Links.Remove(link)); } return(false); }
public virtual bool CheckIfFileExistsInDB(string url) { string fileName = url.Split('/').Last(); Monitor.Enter(lockObjectDb); if (Links.Contains(fileName)) { Monitor.Exit(lockObjectDb); return(true); } Monitor.Exit(lockObjectDb); return(false); }
/// <summary> /// Executes Delaunay triangulation on the Nodes and populates the Links accordingly. /// Note that Links currently existing are not removed by the function. /// </summary> public void Triangulate() { // Triangulate and extract links List <Triangulator.Geometry.Point> nodesToTriangulate = new List <Triangulator.Geometry.Point>(); foreach (var node in Nodes) { nodesToTriangulate.Add(new Triangulator.Geometry.Point(node.NodeX, node.NodeY)); } List <Triangulator.Geometry.Triangle> triangles = Triangulator.Delauney.Triangulate(nodesToTriangulate); foreach (Triangulator.Geometry.Triangle triangle in triangles) { Triangulator.Geometry.Point pt1 = nodesToTriangulate[triangle.p1]; Triangulator.Geometry.Point pt2 = nodesToTriangulate[triangle.p2]; Triangulator.Geometry.Point pt3 = nodesToTriangulate[triangle.p3]; T n1 = Nodes.Find(n => n.NodeX == pt1.X && n.NodeY == pt1.Y); T n2 = Nodes.Find(n => n.NodeX == pt2.X && n.NodeY == pt2.Y); T n3 = Nodes.Find(n => n.NodeX == pt3.X && n.NodeY == pt3.Y); Link <T> l1 = new Link <T>() { From = n1, To = n2, IsDirected = false, Weight = 1 }; Link <T> l2 = new Link <T>() { From = n2, To = n3, IsDirected = false, Weight = 1 }; Link <T> l3 = new Link <T>() { From = n3, To = n1, IsDirected = false, Weight = 1 }; if (!Links.Contains(l1)) { Links.Add(l1); } if (!Links.Contains(l2)) { Links.Add(l2); } if (!Links.Contains(l3)) { Links.Add(l3); } } }
public virtual bool CheckIfFileExistsInDB(string url) { string fileName = url.Split('/').Last(); Monitor.Enter(_lockList); try { return(Links.Contains(fileName)); } finally { Monitor.Exit(_lockList); } }
public void Unlink(ICell cell, bool biDirectional = true) { if (cell is null) { return; } if (!Links.Contains(cell)) { Links.Remove(cell); } if (biDirectional) { cell.Unlink(this, false); } }
public bool Contains(ILink link) { return(Links.Contains(link)); }
public bool Linked(Cell cell) => Links.Contains(cell);
public bool IsLinked(Cell cell) { return(Links.Contains(cell)); }
public bool Contains(LinkModel link) { return(Links.Contains(link)); }