Пример #1
0
        private ISibling CreateSibling(string tag, string siblingType)
        {
            this.tagIndex = this.ExpressionParts.Count;

            if (this.AppliesToParent)
            {
                string parent = this.ExpressionParts[0];

                //find correct parent if there is more than one ancestor of same type
                int ancestorIndex = 1;
                for (int i = this.tagIndex - 1; i > 0; i--)
                {
                    if (this.ExpressionParts[i] == parent)
                    {
                        //must increment to point to the next parent
                        ancestorIndex++;
                    }
                }

                this.ExpressionParts.Add(string.Format("/ancestor::{0}[{1}]", parent.TrimStart('/'), ancestorIndex));
                this.tagIndex++;
            }

            return(SiblingElement.Create(tag, this.ExpressionParts, siblingType, this.tagIndex));
        }
Пример #2
0
        private ISibling CreateSibling(string tag, string type)
        {
            this.tagIndex = this.ExpressionParts.Count;

            if (this.AppliesToParent)
            {
                string parent = this.ExpressionParts.Where(s => s[0] == '/').Reverse().Skip(1).First();
                this.ExpressionParts.Add(string.Format("/ancestor::{0}{1}", parent.TrimStart('/'), "[1]"));

                CloseAndTerm();

                this.tagIndex++;
            }
            else
            {
                this.ExpressionParts[this.ExpressionParts.Count - 1] = "]";
            }

            return(SiblingElement.Create(tag, this.ExpressionParts, type, this.tagIndex));
        }