Irony.Parsing.DsvLiteral.ReadQuotedBody C# (CSharp) Метод

ReadQuotedBody() приватный Метод

private ReadQuotedBody ( ParsingContext context, ISourceStream source ) : string
context ParsingContext
source ISourceStream
Результат string
    private string ReadQuotedBody(ParsingContext context, ISourceStream source) {
      const char dQuoute = '"'; 
      StringBuilder sb = null;
      var from = source.Location.Position + 1; //skip initial double quote
      while(true) {
        var until  = source.Text.IndexOf(dQuoute, from);
        if (until < 0)
          throw new Exception(O2_Misc_Microsoft_MPL_Libs.Irony_Parser.Resources.ErrDsvNoClosingQuote); // "Could not find a closing quote for quoted value."
        source.PreviewPosition = until; //now points at double-quote
        var piece = source.Text.Substring(from, until - from);
        source.PreviewPosition++; //move after double quote
        if (source.PreviewChar != dQuoute && sb == null)
          return piece; //quick path - if sb (string builder) was not created yet, we are looking at the very first segment;
                        // and if we found a standalone dquote, then we are done - the "piece" is the result. 
        if (sb == null)
          sb = new StringBuilder(100);
        sb.Append(piece);
        if (source.PreviewChar != dQuoute)
          return sb.ToString();
        //we have doubled double-quote; add a single double-quoute char to the result and move over both symbols
        sb.Append(dQuoute);
        from = source.PreviewPosition + 1;        
      }
    }