public override bool Read()
{
switch (_state) {
case State.Initial:
if (_csvReader == null) {
throw new Exception("You must provide an input location via the Href property, or provide an input stream via the TextReader property.");
}
if (_firstRowHasColumnNames) {
ReadColumnNames();
}
_state = State.Root;
return true;
case State.Eof:
return false;
case State.Root:
case State.EndRow:
if (_csvReader.Read()) {
_state = State.Row;
return true;
}
_state = State.EndRoot;
return true;
case State.EndRoot:
_state = State.Eof;
return false;
case State.Row:
if (_asAttrs) {
_attr = 0;
goto case State.EndRow;
}
else {
_state = State.Field;
_attr = 0;
return true;
}
case State.Field:
if (!IsEmptyElement) {
_state = State.FieldValue;
}
else {
goto case State.EndField;
}
return true;
case State.FieldValue:
_state = State.EndField;
return true;
case State.EndField:
if (_attr < _csvReader.FieldCount-1) {
_attr++;
_state = State.Field;
return true;
}
_state = State.EndRow;
return true;
case State.Attr:
case State.AttrValue:
_state = State.Root;
_attr = 0;
goto case State.Root;
}
return false;
}