Beispiel #1
0
 public ITextBuffer CreateTextBuffer(ITextImage image, IContentType contentType)
 {
     if (image == null)
     {
         throw new ArgumentNullException(nameof(image));
     }
     return(CreateTextBuffer(image.GetText(), contentType));
 }
        public static StringRebuilder Create(ITextImage image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            var cti = image as CachingTextImage;

            if (cti != null)
            {
                return(cti.Builder);
            }

            // This shouldn't happen but as a fallback, create a new string rebuilder from the text of the provided image.
            return(StringRebuilder.Create(image.GetText(0, image.Length)));
        }
Beispiel #3
0
 /// <summary>
 /// Gets all the text in the image.
 /// </summary>
 /// <returns>A non-null string.</returns>
 /// <remarks>Caveat emptor. Calling GetText() on a 100MB <see cref="ITextImage"/> will give you exactly what you asked for, which
 /// probably isn't what you wanted.</remarks>
 public static string GetText(this ITextImage image)
 {
     return(image.GetText(new Span(0, image.Length)));
 }
Beispiel #4
0
 /// <summary>
 /// Gets text from the image starting at <paramref name="startIndex"/> and having length equal to <paramref name="length"/>.
 /// </summary>
 /// <param name="startIndex">The starting index.</param>
 /// <param name="length">The length of text to get.</param>
 /// <returns>The string of length <paramref name="length"/> starting at <paramref name="startIndex"/> in the underlying <see cref="ITextBuffer"/>.</returns>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than zero or greater than the length of the image,
 /// or <paramref name="length"/> is less than zero, or <paramref name="startIndex"/> plus <paramref name="length"/> is greater than the length of the image.</exception>
 public static string GetText(this ITextImage image, int startIndex, int length)
 {
     return(image.GetText(new Span(startIndex, length)));
 }