SIL.FieldWorks.FDO.Infrastructure.Impl.ElementReader.AdvanceToMarkerElement C# (CSharp) Метод

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

Advance input, copying characters read to m_output if it is non-null, until we have successfully read the target marker, or reached EOF. Return true if we found it. Assumes m_marker is at least two characters. Also expects it to be an XML element marker, or at least that it's first character does not recur in the marker.
private AdvanceToMarkerElement ( ) : bool
Результат bool
		private bool AdvanceToMarkerElement()
		{
			var openingAngleBracket	= m_openingMarker[0];
			int openMarkerLengthMinus1 = m_openingMarker.Length - 1;
			while (true)
			{
				// The first condition is redundant, but should be faster to execute than calling More(), and will almost always fail.
				while (m_currentIndex < m_currentBufLength || More())
				{
					var nextByte = m_currentBuffer[m_currentIndex++];
					// FWR-9296: nulls may be in data that was not completely written to disk
					if (nextByte == 0)
						throw new XmlException("null characters not permitted in XML");
					if (nextByte == openingAngleBracket)
						break;
				}

				if (!More())
					return false;
				// Try to match the rest of the marker.
				for (int i = 1;; i++)
				{
					if (!More())
						return false;
					// FWR-9296: nulls may be in data that was not completely written to disk
					if (m_currentBuffer[m_currentIndex] == 0)
						throw new XmlException("null characters not permitted in XML");
					if (m_openingMarker[i] != m_currentBuffer[m_currentIndex++])
						break; // no match, resume searching for opening character.
					if (i == openMarkerLengthMinus1)
						return true; // got it!
				}
			}
		}