private Visyn.Windows.Io.FileHelper.Core.ExtractedInfo BasicExtractString(LineInfo line) { if (IsLast && !IsArray) { if (line.IndexOf(Separator) == -1) { return(new Visyn.Windows.Io.FileHelper.Core.ExtractedInfo(line)); } // Now check for one extra separator throw new BadUsageException(line.mReader.LineNumber, line.mCurrentPos, $"Delimiter '{Separator}' found after the last field '{FieldInfo.Name}' (the file is wrong or you need to add a field to the record class)"); } var sepPos = line.IndexOf(Separator); if (sepPos != -1) { return(new Visyn.Windows.Io.FileHelper.Core.ExtractedInfo(line, sepPos)); } if (IsLast && IsArray) { return(new Visyn.Windows.Io.FileHelper.Core.ExtractedInfo(line)); } if (NextIsOptional == false) { if (IsFirst && line.EmptyFromPos()) { throw new FileHelpersException(line.mReader.LineNumber, line.mCurrentPos, $"The line {line.mReader.LineNumber} is empty. Maybe you need to use the attribute [IgnoreEmptyLines] in your record class."); } throw new FileHelpersException(line.mReader.LineNumber, line.mCurrentPos, $"Delimiter '{Separator}' not found after field '{FieldInfo.Name}' (the record has less fields, the delimiter is wrong or the next field must be marked as optional)."); } sepPos = line.mLineStr.Length; return(new Visyn.Windows.Io.FileHelper.Core.ExtractedInfo(line, sepPos)); }
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); }