Example #1
0
        public void RemoveChild(TopicNode child)
        {
            var children = ChildNodes.ToList();

            children.Remove(child);

            child._parent   = null;
            child._previous = null;
            child._next     = null;


            if (!children.Any())
            {
                _firstChild = null;
                return;
            }

            _firstChild           = children.First();
            _firstChild._parent   = this;
            _firstChild._previous = null;

            children.Last()._next = null;

            for (int i = 1; i < children.Count; i++)
            {
                children[i]._previous = children[i - 1];
            }

            for (int i = 0; i < children.Count - 1; i++)
            {
                children[i]._next = children[i + 1];
            }
        }
Example #2
0
        public void PrependChild(TopicNode node)
        {
            if (_firstChild != null)
            {
                _firstChild._previous = node;
                node._next            = _firstChild;
            }

            FirstChild = node;
        }
Example #3
0
        public void InsertAfter(TopicNode node)
        {
            if (_next != null)
            {
                _next._previous = node;
                node._next      = _next;
            }

            node._previous = this;
            _next          = node;
        }
Example #4
0
        public void AppendChild(TopicNode node)
        {
            var last = LastChild;

            if (last == null)
            {
                FirstChild = node;
            }
            else
            {
                last.InsertAfter(node);
            }
        }
Example #5
0
        public void InsertBefore(TopicNode node)
        {
            if (_previous == null)
            {
                if (_parent != null)
                {
                    _parent.PrependChild(node);
                }
                else
                {
                    node._next = this;
                    _previous  = node;
                }
            }
            else
            {
                _previous._next = node;
                node._previous  = _previous;

                node._next = this;
                _previous  = node;
            }
        }
Example #6
0
 public TopicExpression(TopicNode parent, TopicGraph graph)
 {
     _parent = parent;
     _graph  = graph;
 }
Example #7
0
 protected bool Equals(TopicNode other)
 {
     return(Equals(_topicType, other._topicType));
 }