public void UnlinkFromAll(Linkable unlinked, int usrId) { foreach (var edge in unlinked.GetEdge().ToArray()) { Unlink(unlinked, edge.next, usrId); } }
public Edge(Linkable curr, Linkable next, int linkShapeId, bool forward) { this.curr = curr; this.next = next; this.linkShapeId = linkShapeId; this.forward = forward; }
public Edge RemoveEdge(Linkable next) { Edge toRemove = null; foreach (var e in _edges) if (e.next == next) toRemove = e; _edges.Remove(toRemove); return toRemove; }
private void __linkRemove(Linkable end1, Linkable end2, int linkShapeId, int usrId) { UnlockDeleteBroadcast(linkShapeId, usrId); EventLogger.LogAndBroadcast(new DiscCtx(Discussions.ConfigManager.ConnStr), _room, StEvent.LinkRemoved, usrId, _topicId); _pendingChanges = true; }
public Edge RemoveEdge(Linkable next) { Edge toRemove = null; foreach (var e in _edges) { if (e.next == next) { toRemove = e; } } _edges.Remove(toRemove); return(toRemove); }
private void __onLinkableDeleted(Linkable end, int usrId) { UnlockDeleteBroadcast(end.GetId(), usrId); //record event if (end is Cluster) { EventLogger.LogAndBroadcast(new DiscCtx(Discussions.ConfigManager.ConnStr), _room, StEvent.ClusterDeleted, -1, //owner unknown _topicId); } _pendingChanges = true; }
public void Link(Linkable end1, Linkable end2, int linkShapeId) { if (end1 == end2) { throw new NotSupportedException("no self loops"); } if (end1.HasAdjacent(end2)) { throw new NotSupportedException("no multiedges"); } var fwd = new Edge(end1, end2, linkShapeId, true); _forwardEdges.Add(linkShapeId, fwd); end1.AddEdge(fwd); end2.AddEdge(new Edge(end2, end1, linkShapeId, false)); }
public void Unlink(Linkable end1, Linkable end2, int usrId) { if (end1 == end2) { throw new NotSupportedException("no self loops"); } if (!end1.HasAdjacent(end2)) { throw new NotSupportedException("no link"); } var edge1 = end1.RemoveEdge(end2); if (edge1.forward) { _forwardEdges.Remove(edge1.linkShapeId); } var edge2 = end2.RemoveEdge(end1); if (edge2.forward) { _forwardEdges.Remove(edge2.linkShapeId); } if (edge1.linkShapeId != edge2.linkShapeId) { throw new NotSupportedException("?"); } if (onLinkRemove != null) { onLinkRemove(end1, end2, edge1.linkShapeId, usrId); } }
public bool HasAdjacent(Linkable next) { return _edges.FirstOrDefault(edge => edge.next == next) != null; }
public void UnlinkFromAll(Linkable unlinked, int usrId) { foreach (var edge in unlinked.GetEdge().ToArray()) Unlink(unlinked, edge.next, usrId); }
public void Unlink(Linkable end1, Linkable end2, int usrId) { if (end1 == end2) throw new NotSupportedException("no self loops"); if (!end1.HasAdjacent(end2)) throw new NotSupportedException("no link"); var edge1 = end1.RemoveEdge(end2); if (edge1.forward) _forwardEdges.Remove(edge1.linkShapeId); var edge2 = end2.RemoveEdge(end1); if (edge2.forward) _forwardEdges.Remove(edge2.linkShapeId); if (edge1.linkShapeId != edge2.linkShapeId) throw new NotSupportedException("?"); if (onLinkRemove != null) onLinkRemove(end1, end2, edge1.linkShapeId, usrId); }
public void Link(Linkable end1, Linkable end2, int linkShapeId) { if (end1 == end2) throw new NotSupportedException("no self loops"); if (end1.HasAdjacent(end2)) throw new NotSupportedException("no multiedges"); var fwd = new Edge(end1, end2, linkShapeId, true); _forwardEdges.Add(linkShapeId, fwd); end1.AddEdge(fwd); end2.AddEdge(new Edge(end2, end1, linkShapeId, false)); }
public bool HasAdjacent(Linkable next) { return(_edges.FirstOrDefault(edge => edge.next == next) != null); }