protected static void UpdateParent(XmlExpressionNode node, XmlExpressionNode parent)
 {
     if (ReferenceEquals(node.Parent, parent))
     {
         return;
     }
     node.Parent = parent;
 }
Exemple #2
0
 public bool RemoveAttribute([NotNull] XmlExpressionNode node)
 {
     Should.NotBeNull(node, nameof(node));
     if (_attributes.Remove(node))
     {
         UpdateParent(node, null);
         return(true);
     }
     return(false);
 }
Exemple #3
0
 public void AddAttribute([NotNull] XmlExpressionNode node)
 {
     Should.NotBeNull(node, nameof(node));
     if (_attributes.Contains(node))
     {
         return;
     }
     _attributes.Add(node);
     UpdateParent(node, this);
 }
Exemple #4
0
 public void AddElement([NotNull] XmlExpressionNode node)
 {
     Should.NotBeNull(node, nameof(node));
     if (_elements.Contains(node))
     {
         return;
     }
     _elements.Add(node);
     UpdateParent(node, this);
 }
 public bool RemoveElement([NotNull] XmlExpressionNode node)
 {
     Should.NotBeNull(node, "node");
     if (_elements.Remove(node))
     {
         UpdateParent(node, null);
         return(true);
     }
     return(false);
 }
Exemple #6
0
        protected override void AcceptInternal(IExpressionVisitor visitor)
        {
            StartTag = AcceptWithCheck(visitor, StartTag, true);
            if (StartTagEnd != null)
            {
                StartTagEnd = AcceptWithCheck(visitor, StartTagEnd, true);
            }
            if (EndTag != null)
            {
                EndTag = AcceptWithCheck(visitor, EndTag, true);
            }
            for (int i = 0; i < _elements.Count; i++)
            {
                XmlExpressionNode node = AcceptWithCheck(visitor, _elements[i], false);
                if (node == null)
                {
                    _elements.RemoveAt(i);
                    i--;
                }
                else
                {
                    _elements[i] = node;
                }
            }

            for (int i = 0; i < _attributes.Count; i++)
            {
                XmlExpressionNode node = AcceptWithCheck(visitor, _attributes[i], false);
                if (node == null)
                {
                    _attributes.RemoveAt(i);
                    i--;
                }
                else
                {
                    _attributes[i] = node;
                }
            }
        }
Exemple #7
0
 public XmlValueExpressionNode(XmlExpressionNode parent, XmlValueExpressionType type, int start, int end)
     : this(type, start, end)
 {
     UpdateParent(this, parent);
 }