internal void FinishIncrementalRead(XmlTextReader reader) { if (null != _BinHexDecoder) { _BinHexDecoder.Flush(); } if (null != _Base64Decoder) { _Base64Decoder.Flush(); } while(true) { if (_nPos == _nUsed) { _nStart = _nPos; int i = Read(); if (0 == i ) return; } if ('<' == _achText[_nPos]) { if (!reader.ContinueReadFromBuffer(ScanMarkup())) { return; } } _nPos++; } }
internal int IncrementalRead(object destBuffer, int index, int count, XmlTextReader reader,IncrementalReadType readType ) { int nStart = _nPos; int initialDestStartIndex = index; int loopCount; int offset = index; int lineNumber = LineNum; int linePosition = LinePos; bool lastCharD = false; int i; loopCount = GetCharCount(count, readType); try { for(i = 0; i < loopCount; i++) { if (_nPos == _nUsed) { index = IncrementalReadHelper(destBuffer, index, readType, nStart, count - index + offset); _nStart = _nPos; int diff = count - index + offset ; if (IncrementalReadType.Base64 == readType || IncrementalReadType.BinHex == readType ) { loopCount += GetCharCount(diff , readType); } if (diff == 0) return index - initialDestStartIndex; if (Read() == 0) throw new XmlException(Res.Xml_UnexpectedEOF, XmlToken.ToString(XmlToken.TAG), LineNum, LinePos); nStart = _nPos; lineNumber = LineNum; linePosition = LinePos; } switch(_achText[_nPos]) { case '<': { index = IncrementalReadHelper(destBuffer, index, readType, nStart, count - index + offset); int diff = count - index + offset ; if (IncrementalReadType.Base64 == readType || IncrementalReadType.BinHex == readType ) { loopCount += GetCharCount(diff , readType); } if (diff == 0) return index - initialDestStartIndex; } // Refill buffer to ensure that the calls from ContinueReadFromBuffer will not cause // The buffer size to increase _nStart = _nPos; Read(); //as its not end of input we just calling read to make sure buffer is enough full so no need to check the result nStart = _nPos; lineNumber = LineNum; linePosition = LinePos; // set ReadBufferConsistency in case name of the tag is bigger than 4k. Highly unlikely but possible. if (reader.ContinueReadFromBuffer(ScanMarkup())) { // We can continue filling up the buffer but _nPos might have moved. if (nStart < _nPos) { // Some stuff was read by the textReader; if (_nPos - nStart > loopCount - (index - offset)) { _nPos = nStart + loopCount - (index - offset); i = loopCount - 1; _nStart = _nPos; } else { i += _nPos - nStart -1; } } //if (nStart < _nPos) } else { return index - initialDestStartIndex; } // if ... else ... lastCharD = false; break; case (char)0xA: if (!lastCharD) { ++_nLineNum; } _nPos++; _nLinePos = _nPos; lastCharD = false; break; case (char)0xD: ++_nLineNum; lastCharD = true; _nPos++; _nLinePos = _nPos; break; default: _nPos++; lastCharD = false; break; } if (i == loopCount -1) { index = IncrementalReadHelper(destBuffer, index, readType, nStart, count - index + offset); int diff = count - index + offset ; if (IncrementalReadType.Base64 == readType || IncrementalReadType.BinHex == readType ) { loopCount += GetCharCount(diff , readType); } nStart = _nStart = _nPos; lineNumber = LineNum; linePosition = LinePos; if (diff == 0) return index - initialDestStartIndex; } } } catch (XmlException e) { throw new XmlException(e.ErrorCode, e.msg, lineNumber, linePosition); } return index - initialDestStartIndex; }