Пример #1
0
        public void Replace(RelatedLocation location, LazyString replacement)
        {
            // only tail replacing
            if (location.StartIndex < TailStartIndex)
            {
                return;
            }

            var tail = _workingText.Last.Value;

            var beforeLength = location.StartIndex - TailStartIndex;
            var afterLength  = tail.Length - beforeLength - location.Length;

            _workingText.RemoveLast();

            // tail_1_2_3 -> tail_1 + replacement + tail_3
            if (beforeLength > 0)
            {
                _workingText.Append(tail.Substring(0, beforeLength));
            }
            _workingText.Append(replacement);
            if (afterLength > 0)
            {
                _workingText.Append(tail.Substring(beforeLength + location.Length, afterLength));
            }

            TotalLegthCorrection.Value += replacement.Length - location.Length;
        }
Пример #2
0
 public Replacement()
 {
     _replacementString = string.Empty;
     _parcedWorkingCopy.Append(new LazySubstring());
 }