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); }
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); }
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)); }
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)); }
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)); }
internal abstract Text AppendSimpleText(SimpleText tail);
internal abstract bool IsSimpleTextAppendableTo(SimpleText tail);