Example #1
0
        public static StringSelection TryCreate(StringLocation start, int length)
        {
            if (!start.IsValid)
            {
                return(new StringSelection(start, -1));
            }
            var end = start.Skip(length);

            if (!end.IsValid)
            {
                return(new StringSelection(start, -1));
            }
            return(new StringSelection(start, end));
        }
Example #2
0
 public StringSelection(StringLocation start, int length)
 {
     if (start == null)
     {
         throw new ArgumentNullException("start");
     }
     _Start  = start;
     _Length = length;
     _Text   = null;
     if (_Length < 0)
     {
         _End = null;
     }
     else
     {
         _End = start.Skip(length);
         if (!_End.IsValid)
         {
             throw new Exception("String selection out of bounds");
         }
     }
 }