public bool MoveNext()
{
// No events after the end of the stream or error.
if (state == ParserState.StreamEnd)
{
currentEvent = null;
return false;
}
else if (pendingEvents.Count == 0)
{
// Generate the next event.
pendingEvents.Enqueue(StateMachine());
}
currentEvent = pendingEvents.Dequeue();
return true;
}