Пример #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;
        }