Ejemplo n.º 1
0
 public CompositeSegment?Next()
 {
     while (_currentIndex < _compositeFormatString.Length)
     {
         char c = _compositeFormatString[_currentIndex];
         if (c == '{')
         {
             if (_state == State.Literal)
             {
                 _state = State.New;
                 return(CompositeSegment.Literal(_spanStart, _currentIndex));
             }
             _currentIndex++;
             return(ParseInsertionPoint());
         }
         else
         {
             if (_state != State.Literal)
             {
                 _state     = State.Literal;
                 _spanStart = _currentIndex;
             }
         }
         _currentIndex++;
     }
     if (_state == State.Literal)
     {
         _state = State.New;
         return(CompositeSegment.Literal(_spanStart, _currentIndex));
     }
     return(null);
 }
Ejemplo n.º 2
0
 public CompositeSegment?Next()
 {
     while (_currentIndex < _compositeFormatString.Length)
     {
         char c = _compositeFormatString[_currentIndex];
         if (c == '{')
         {
             if (_state == State.Literal)
             {
                 _state = State.New;
                 return(CompositeSegment.Literal(_spanStart, _currentIndex));
             }
             if ((_currentIndex + 1 < _compositeFormatString.Length) && (_compositeFormatString[_currentIndex + 1] == c))
             {
                 _state = State.Literal;
                 _currentIndex++;
                 _spanStart = _currentIndex;
             }
             else
             {
                 _currentIndex++;
                 return(ParseInsertionPoint());
             }
         }
         else if (c == '}')
         {
             if ((_currentIndex + 1 < _compositeFormatString.Length) && (_compositeFormatString[_currentIndex + 1] == c))
             {
                 if (_state == State.Literal)
                 {
                     _state = State.New;
                     return(CompositeSegment.Literal(_spanStart, _currentIndex));
                 }
                 _state = State.Literal;
                 _currentIndex++;
                 _spanStart = _currentIndex;
             }
             else
             {
                 throw new Exception("missing start bracket");
             }
         }
         else
         {
             if (_state != State.Literal)
             {
                 _state     = State.Literal;
                 _spanStart = _currentIndex;
             }
         }
         _currentIndex++;
     }
     if (_state == State.Literal)
     {
         _state = State.New;
         return(CompositeSegment.Literal(_spanStart, _currentIndex));
     }
     return(null);
 }