示例#1
0
        internal override Text AppendSimpleText(SimpleText tail)
        {
            Debug.Assert(tail != null);
            Debug.Assert(tail.Length > 0);
            Debug.Assert(this.Length > 0);

            var text = IsSimpleTextAppendableTo(tail) ?
                       new ComplexText(
                this.texts.Take(this.texts.Count - 1)
                .Concat(new[] { this.texts.Last().AppendSimpleText(tail) }),
                enableOptimizations: false) :
                       new ComplexText(
                this.texts.Concat(new[] { tail }),
                enableOptimizations: false);

            var texts = text.texts;

            if (texts.Count == 0)
            {
                return(Text.Empty);
            }
            if (texts.Count == 1)
            {
                return(text.texts[0]);
            }
            return(text);
        }
示例#2
0
        internal override bool IsSimpleTextAppendableTo(SimpleText tail)
        {
            Debug.Assert(tail != null);
            Debug.Assert(tail.Length > 0);
            Debug.Assert(this.Length > 0);

            return
                (object.ReferenceEquals(this.value, tail.value) &&
                 this.index + this.length == tail.index);
        }
示例#3
0
        public override SplitText Split(int index)
        {
            if (index < 0 || index > this.length)
            {
                throw new ArgumentOutOfRangeException("The index is out of the bounds of the Text.");
            }

            var head = new SimpleText(this.value, this.index, index);
            var tail = new SimpleText(this.value, this.index + index, this.length - index);

            return(new SplitText(head, tail));
        }
示例#4
0
        internal override bool IsSimpleTextAppendableTo(SimpleText tail)
        {
            Debug.Assert(tail != null);
            Debug.Assert(tail.Length > 0);
            Debug.Assert(this.Length > 0);

            var lastComponent = this.texts[this.texts.Count - 1] as SimpleText;

            return
                (lastComponent != null &&
                 lastComponent.IsSimpleTextAppendableTo(tail));
        }
示例#5
0
        internal override Text AppendSimpleText(SimpleText tail)
        {
            Debug.Assert(tail != null);
            Debug.Assert(tail.Length > 0);
            Debug.Assert(this.Length > 0);

            if (IsSimpleTextAppendableTo(tail))
            {
                return(new SimpleText(this.value, this.index, this.length + tail.length));
            }

            return(Text.Join(this, tail));
        }
示例#6
0
 internal abstract Text AppendSimpleText(SimpleText tail);
示例#7
0
 internal abstract bool IsSimpleTextAppendableTo(SimpleText tail);