Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 public StringSelection(StringLocation start, StringLocation end)
 {
     if (start == null)
     {
         throw new ArgumentNullException("start");
     }
     if (end == null)
     {
         throw new ArgumentNullException("end");
     }
     _Start  = start;
     _End    = end;
     _Length = _End.Index - _Start.Index;
     _Text   = null;
     if (!_Start.IsValid && !_End.IsValid)
     {
         throw new Exception("String selection out of bounds");
     }
 }
Ejemplo n.º 3
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");
         }
     }
 }