Ejemplo n.º 1
0
        /// <summary>
        /// Matches a text without setting an error if matches fails.
        /// </summary>
        /// <param name="text">The string that must match. Can not be null nor empty.</param>
        /// <param name="comparisonType">Specifies the culture, case, and sort rules.</param>
        /// <returns></returns>
        public bool TryMatchText(string text, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentException(nameof(text));
            }
            int len = text.Length;

            return(!IsEnd &&
                   len <= _length &&
                   string.Compare(_text.GetText(_startIndex, len), 0, text, 0, len, comparisonType) == 0
                ? UncheckedMove(len)
                : false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns a substring of the Virtual String.
 /// It calls <see cref="IVirtualString.GetText(long, int)"/> on <see cref="Text"/>.
 /// </summary>
 /// <param name="index">The index where we want to start the substring.</param>
 /// <param name="length">The length of the substring.</param>
 /// <returns>The string containing characters in the range.</returns>
 public string GetText(long index, int length)
 {
     return(_text.GetText(index, length));
 }