Ejemplo n.º 1
0
 public void ReserveAll(Token token)
 {
     foreach (var c in Chars)
     {
         Reserve(c.Position, token);
     }
 }
Ejemplo n.º 2
0
        public void Reserve(int index, Token token)
        {
            if (index >= Chars.Count)
                throw new IndexOutOfRangeException();
            if (Chars[index].ReservedBy != null)
                throw new PositionAlreadyReservedException(index);

            token.Parent = Chars[index].ReservedBy;
            Chars[index].ReservedBy = token;
        }
Ejemplo n.º 3
0
        public void ReserveFromStartAndStopChar(char startChar, char endChar, Token token)
        {
            var currentString = ToStringOnlyNoneReserved();
            int start = currentString.IndexOf(startChar);
            if (start == -1) throw new CharNotFoundInStringException(startChar);

            int end = currentString.IndexOf(endChar, start + 1);
            if (end == -1) throw new CharNotFoundInStringException(startChar, start); ;

            ReserveRange(start, end, token);
        }
Ejemplo n.º 4
0
        public void ReserveRange(int from, int to, Token token)
        {
            if (from > to) throw new ArgumentException("From needs to be less or equal to to");

            for (int i = from; i <= to; i++) Reserve(i, token);
        }
Ejemplo n.º 5
0
 public string GetReserved(Token token)
 {
     return String.Concat(Chars.OrderBy(c => c.Position).Where(c => c.ReservedBy != null && c.ReservedBy.Id == token.Id).Select(c => c.Char));
 }