public override string ReadLine()
{
if (_stream == null)
{
throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
}
CheckAsyncTaskInProgress();
if (_charPos == _charLen)
{
if (ReadBuffer() == 0)
{
return null;
}
}
StringBuilder sb = null;
do
{
int i = _charPos;
do
{
char ch = _charBuffer[i];
// Note the following common line feed chars:
// \n - UNIX \r\n - DOS \r - Mac
if (ch == '\r' || ch == '\n')
{
string s;
if (sb != null)
{
sb.Append(_charBuffer, _charPos, i - _charPos);
s = sb.ToString();
}
else
{
s = new string(_charBuffer, _charPos, i - _charPos);
}
_charPos = i + 1;
if (ch == '\r' && (_charPos < _charLen || ReadBuffer() > 0))
{
if (_charBuffer[_charPos] == '\n')
{
_charPos++;
}
}
return s;
}
i++;
} while (i < _charLen);
i = _charLen - _charPos;
if (sb == null)
{
sb = new StringBuilder(i + 80);
}
sb.Append(_charBuffer, _charPos, i);
} while (ReadBuffer() > 0);
return sb.ToString();
}