Beispiel #1
0
        public long GetLength(TextSegment_I textSegment)
        {
            if (textSegment == null)
            {
                return(0);
            }

            return(textSegment.EndPosition - textSegment.StartPosition + 1);
        }
Beispiel #2
0
        public long GetStartCaretPosition(TextSegment_I textSegment)
        {
            if (textSegment == null)
            {
                return(-1);
            }

            return(textSegment.StartPosition);
        }
Beispiel #3
0
        public long GetEndCaretPosition(TextSegment_I textSegment)
        {
            if (textSegment == null)
            {
                return(-1);
            }

            return(textSegment.EndPosition + 1);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
 /// <summary>
 /// Gets or sets the start position of the segment
 /// </summary>
 public static long StartCaretPosition(this TextSegment_I segment)
 {
     return(XTextual.TextSegments.GetStartCaretPosition(segment));
 }
Beispiel #7
0
 /// <summary>
 /// Gets the length of the segment
 /// </summary>
 public static long Length(this TextSegment_I segment)
 {
     return(XTextual.TextSegments.GetLength(segment));
 }
Beispiel #8
0
 /// <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));
 }
Beispiel #9
0
 public string GetValue(TextSegment_I segment, TextSourceFile source)
 {
     throw new System.NotImplementedException();
 }
Beispiel #10
0
 public string GetValue(TextSegment_I textSegment)
 {
     return(XTextual.TextSources.GetValue(textSegment));
 }