private ExtractedInfo BasicExtractString(LineInfo line) { ExtractedInfo res; if (mIsLast) res = new ExtractedInfo(line); else { int sepPos; sepPos = line.IndexOf(mSeparator); if (sepPos == -1) { if (mNextIsOptional == false) { string msg = null; if (mIsFirst && line.EmptyFromPos()) msg = "The line " + line.mReader.LineNumber.ToString() + " is empty. Maybe you need to use the attribute [IgnoreEmptyLines] in your record class."; else msg = "The delimiter '" + mSeparator + "' can´t be found after the field '" + mFieldInfo.Name + "' at line " + line.mReader.LineNumber.ToString() + " (the record has less fields, the delimiter is wrong or the next field must be marked as optional)."; throw new FileHelpersException(msg); } else sepPos = line.mLine.Length - 1; } res = new ExtractedInfo(line, sepPos); } return res; }
// object[] values, int index, ForwardReader reader internal object ExtractValue(LineInfo line) { //-> extract only what I need if (mInNewLine) { if (line.EmptyFromPos() == false) throw new BadUsageException("Text '" + line.CurrentString + "' found before the new line of the field: " + mFieldInfo.Name + " (this is not allowed when you use [FieldInNewLine])"); line.ReLoad(line.mReader.ReadNextLine()); if (line.mLineStr == null) throw new BadUsageException("End of stream found parsing the field " + mFieldInfo.Name + ". Please check the class record."); } var info = ExtractFieldString(line); if (info.mCustomExtractedString == null) line.mCurrentPos = info.ExtractedTo + 1; line.mCurrentPos += mCharsToDiscard; //total; return AssignFromString(info, line); //-> discard the part that I use //TODO: Uncoment this for Quoted Handling // if (info.NewRestOfLine != null) // { // if (info.NewRestOfLine.Length < CharsToDiscard()) // return info.NewRestOfLine; // else // return info.NewRestOfLine.Substring(CharsToDiscard()); // } // else // { // int total; // if (info.CharsRemoved >= line.mLine.Length) // total = line.mLine.Length; // else // total = info.CharsRemoved + CharsToDiscard(); //return buffer.Substring(total); // } }