コード例 #1
0
 public ForeachNode(ForeachNode original)
     : base(original)
 {
     this.ValueProvider   = original.ValueProvider;
     this.ForeachToken    = original.ForeachToken.CloneNode();
     this.EndForeachToken = original.EndForeachToken.CloneNode();
     this.ForeachBlock    = (BlockNode?)original.ForeachBlock?.Let(a => a.CloneNode(true));
 }
コード例 #2
0
        public OpenXmlElement CommonParent(MatchNodePair other)
        {
            if (this.AscendantNode.Parent != other.AscendantNode.Parent)
            {
                throw new InvalidOperationException("Parents do not match");
            }

            return(this.AscendantNode.Parent);
        }
コード例 #3
0
        public AnyNode(AnyNode original)
            : base(original)
        {
            this.ValueProvider = original.ValueProvider;
            this.Operation     = original.Operation;
            this.Value         = original.Value;

            this.AnyToken    = original.AnyToken.CloneNode();
            this.NotAnyToken = original.NotAnyToken.CloneNode();
            this.EndAnyToken = original.EndAnyToken.CloneNode();

            this.AnyBlock    = (BlockNode)original.AnyBlock?.Let(a => a.CloneNode(true));
            this.NotAnyBlock = (BlockNode)original.NotAnyBlock?.Let(a => a.CloneNode(true));
        }
コード例 #4
0
        public IfNode(IfNode original)
            : base(original)
        {
            this.ValueProvider = original.ValueProvider;
            this.Operation     = original.Operation;
            this.Value         = original.Value;

            this.IfToken    = original.IfToken.CloneNode();
            this.ElseToken  = original.ElseToken.CloneNode();
            this.EndIfToken = original.EndIfToken.CloneNode();

            this.IfBlock   = (BlockNode)original.IfBlock?.Let(a => a.CloneNode(true));
            this.ElseBlock = (BlockNode)original.ElseBlock?.Let(a => a.CloneNode(true));
        }
コード例 #5
0
        protected void NormalizeInterval(ref MatchNodePair first, ref MatchNodePair last, MatchNode errorHintParent)
        {
            if (first.MatchNode == last.MatchNode)
            {
                throw new ArgumentException("first and last are the same node");
            }

            var chainFirst = ((OpenXmlElement)first.MatchNode).Follow(a => a.Parent).Reverse().ToList();
            var chainLast  = ((OpenXmlElement)last.MatchNode).Follow(a => a.Parent).Reverse().ToList();

            var result = chainFirst.Zip(chainLast, (f, l) => new { f, l }).First(a => a.f != a.l);

            AssertNotImportant(chainFirst, result.f !, errorHintParent, first.MatchNode, last.MatchNode); /*CSBUG*/
            AssertNotImportant(chainLast, result.l !, errorHintParent, last.MatchNode, first.MatchNode);

            first.AscendantNode = result.f !;
            last.AscendantNode  = result.l !;
        }
コード例 #6
0
        protected static List <OpenXmlElement> NodesBetween(MatchNodePair first, MatchNodePair last)
        {
            var parent = first.CommonParent(last);

            int indexFirst = parent.ChildElements.IndexOf(first.AscendantNode);

            if (indexFirst == -1)
            {
                throw new InvalidOperationException("Element not found");
            }

            int indexLast = parent.ChildElements.IndexOf(last.AscendantNode);

            if (indexLast == -1)
            {
                throw new InvalidOperationException("Element not found");
            }

            var childs = parent.ChildElements.Where((e, i) => indexFirst < i && i < indexLast).ToList();

            return(childs);
        }
コード例 #7
0
        public IfNode(IfNode original)
            : base(original)
        {
            this.ValueProvider = original.ValueProvider;
            this.Operation = original.Operation;
            this.Value = original.Value;

            this.IfToken = original.IfToken.CloneNode();
            this.ElseToken = original.ElseToken.CloneNode();
            this.EndIfToken = original.EndIfToken.CloneNode();

            this.IfBlock = (BlockNode)original.IfBlock.Try(a => a.CloneNode(true));
            this.ElseBlock = (BlockNode)original.ElseBlock.Try(a => a.CloneNode(true));
        }
コード例 #8
0
        public AnyNode(AnyNode original)
            : base(original)
        {
            this.ValueProvider = original.ValueProvider;
            this.Operation = original.Operation;
            this.Value = original.Value;

            this.AnyToken = original.AnyToken.CloneNode();
            this.NotAnyToken = original.NotAnyToken.CloneNode();
            this.EndAnyToken = original.EndAnyToken.CloneNode();

            this.AnyBlock = (BlockNode)original.AnyBlock.Try(a => a.CloneNode(true));
            this.NotAnyBlock = (BlockNode)original.NotAnyBlock.Try(a => a.CloneNode(true));
        }
コード例 #9
0
        public OpenXmlElement CommonParent(MatchNodePair other)
        {
            if (this.AscendantNode.Parent != other.AscendantNode.Parent)
                throw new InvalidOperationException("Parents do not match");

            return this.AscendantNode.Parent;
        }
コード例 #10
0
 public ForeachNode(ForeachNode original)
     : base(original)
 {
     this.ValueProvider = original.ValueProvider;
     this.ForeachToken = original.ForeachToken.CloneNode();
     this.EndForeachToken = original.EndForeachToken.CloneNode();
     this.ForeachBlock = (BlockNode)original.ForeachBlock.Try(a => a.CloneNode(true));
 }
コード例 #11
0
        protected static List<OpenXmlElement> NodesBetween(MatchNodePair first, MatchNodePair last)
        {
            var parent = first.CommonParent(last);

            int indexFirst = parent.ChildElements.IndexOf(first.AscendantNode);
            if (indexFirst == -1)
                throw new InvalidOperationException("Element not found");

            int indexLast = parent.ChildElements.IndexOf(last.AscendantNode);
            if (indexLast == -1)
                throw new InvalidOperationException("Element not found");

            var childs = parent.ChildElements.Where((e, i) => indexFirst < i && i < indexLast).ToList();
            return childs;
        }
コード例 #12
0
        protected void NormalizeInterval(ref MatchNodePair first, ref MatchNodePair last, MatchNode errorHintParent)
        {
            if (first.MatchNode == last.MatchNode)
                throw new ArgumentException("first and last are the same node");

            var chainFirst = ((OpenXmlElement)first.MatchNode).Follow(a => a.Parent).Reverse().ToList();
            var chainLast = ((OpenXmlElement)last.MatchNode).Follow(a => a.Parent).Reverse().ToList();

            var result = chainFirst.Zip(chainLast, (f, l) => new { f, l }).First(a => a.f != a.l);
            AssertNotImportant(chainFirst, result.f, errorHintParent, first.MatchNode, last.MatchNode);
            AssertNotImportant(chainLast, result.l, errorHintParent, last.MatchNode, first.MatchNode);

            first.AscendantNode = result.f;
            last.AscendantNode = result.l;
        }