public long GetLength(TextSegment_I textSegment) { if (textSegment == null) { return(0); } return(textSegment.EndPosition - textSegment.StartPosition + 1); }
public long GetStartCaretPosition(TextSegment_I textSegment) { if (textSegment == null) { return(-1); } return(textSegment.StartPosition); }
public long GetEndCaretPosition(TextSegment_I textSegment) { if (textSegment == null) { return(-1); } return(textSegment.EndPosition + 1); }
public string GetValue(TextSegment_I segment, TextSourceString source) { if (segment.CachedValue != null) { return(segment.CachedValue); } string substringValue; if (segment.StartPosition <= int.MaxValue && segment.Length() <= int.MaxValue) { substringValue = source.Content.Substring((int)segment.StartPosition, (int)segment.Length()); } else { throw new NotSupportedException("Strings do not support sizes greather than Int32.Max or 2,147,483,647."); } return(substringValue); }
/// <summary> /// Gets the value of the text source. /// </summary> /// <param name="segment"></param> /// <returns></returns> public string GetValue(TextSegment_I segment) { var source = segment.Source; string result; switch (source.Type) { case TextSourceType.File: { result = XTextual.TextSources.Files.GetValue(segment, (TextSourceFile)source); break; } case TextSourceType.Stream: { result = XTextual.TextSources.Streams.GetValue(segment, (TextSourceStream)source); break; } case TextSourceType.String: { result = XTextual.TextSources.Strings.GetValue(segment, (TextSourceString)source); break; } default: { throw XExceptions.Exception("TextSourceType is not supported."); } } if (segment.SupportsCachedValue) { segment.CachedValue = result; } return(result); }
/// <summary> /// Gets or sets the start position of the segment /// </summary> public static long StartCaretPosition(this TextSegment_I segment) { return(XTextual.TextSegments.GetStartCaretPosition(segment)); }
/// <summary> /// Gets the length of the segment /// </summary> public static long Length(this TextSegment_I segment) { return(XTextual.TextSegments.GetLength(segment)); }
/// <summary> /// Gets the value of the text segment. /// </summary> /// <returns>The actual string value of the text segment from the source.</returns> public static string GetValue(this TextSegment_I segment) { return(XTextual.TextSegments.GetValue(segment)); }
public string GetValue(TextSegment_I segment, TextSourceFile source) { throw new System.NotImplementedException(); }
public string GetValue(TextSegment_I textSegment) { return(XTextual.TextSources.GetValue(textSegment)); }