Exemple #1
0
        public void ChangeNode(INode node, string newValue)
        {
            if (_nodeChangeItems.Any(v => v.Node == node &&
                                     (v.ChangeType == NodeChangeType.Change ||
                                      v.ChangeType == NodeChangeType.Delete)))
            {
                throw new Exception("ChangeItems already have this node. Delete first");
            }
            if (_nodeChangeItems.Any(v => v.Node.Pos < node.Pos && v.Node.End > node.Pos))
            {
                throw new Exception("ChangeItems already have node that contains this node. Delete first");
            }

            if (newValue != node.GetTextWithComments())
            {
                var nodeCh = new NodeChangeItem {
                    ChangeType = NodeChangeType.Change, Node = node, NewValue = newValue
                };
                _nodeChangeItems.Add(nodeCh);
            }
            else
            {
                throw new Exception("Same value");
            }
        }
Exemple #2
0
        public void Delete(INode node)
        {
            if (node != null)
            {
                if (_nodeChangeItems.Any(v => v.Node.Pos < node.Pos && v.Node.End > node.Pos))
                {
                    throw new Exception("ChangeItems already have node that contains this node. Delete first");
                }

                var nodeCh = new NodeChangeItem {
                    ChangeType = NodeChangeType.Delete, Node = node
                };
                _nodeChangeItems.Add(nodeCh);
            }
        }
Exemple #3
0
        public void InsertAfter(INode node, string newValue)
        {
            if (node != null)
            {
                //if (_nodeChangeItems.Any(v => v.Node.Pos < node.Pos && v.Node.End > node.Pos))
                //    throw new Exception("ChangeItems already have node that contains this node. Delete first");

                var nodeCh = new NodeChangeItem
                {
                    ChangeType = NodeChangeType.InsertAfter,
                    Node       = node,
                    NewValue   = newValue
                };
                _nodeChangeItems.Add(nodeCh);
            }
        }