예제 #1
0
 public void UnlinkFromAll(Linkable unlinked, int usrId)
 {
     foreach (var edge in unlinked.GetEdge().ToArray())
     {
         Unlink(unlinked, edge.next, usrId);
     }
 }
예제 #2
0
 public Edge(Linkable curr, Linkable next, int linkShapeId, bool forward)
 {
     this.curr = curr;
     this.next = next;
     this.linkShapeId = linkShapeId;
     this.forward = forward;
 }
예제 #3
0
 public Edge(Linkable curr, Linkable next, int linkShapeId, bool forward)
 {
     this.curr        = curr;
     this.next        = next;
     this.linkShapeId = linkShapeId;
     this.forward     = forward;
 }
예제 #4
0
        public Edge RemoveEdge(Linkable next)
        {
            Edge toRemove = null;
            foreach (var e in _edges)
                if (e.next == next)
                    toRemove = e;

            _edges.Remove(toRemove);
            return toRemove;
        }
예제 #5
0
        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;
        }
예제 #6
0
        public Edge RemoveEdge(Linkable next)
        {
            Edge toRemove = null;

            foreach (var e in _edges)
            {
                if (e.next == next)
                {
                    toRemove = e;
                }
            }

            _edges.Remove(toRemove);
            return(toRemove);
        }
예제 #7
0
        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;
        }
예제 #8
0
        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));
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
 public bool HasAdjacent(Linkable next)
 {
     return _edges.FirstOrDefault(edge => edge.next == next) != null;
 }
예제 #11
0
 public void UnlinkFromAll(Linkable unlinked, int usrId)
 {
     foreach (var edge in unlinked.GetEdge().ToArray())
         Unlink(unlinked, edge.next, usrId);
 }
예제 #12
0
        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);
        }
예제 #13
0
        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));
        }
예제 #14
0
 public bool HasAdjacent(Linkable next)
 {
     return(_edges.FirstOrDefault(edge => edge.next == next) != null);
 }
예제 #15
0
        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;
        }
예제 #16
0
        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;
        }