本文整理汇总了C#中FileHelpers.LineInfo.ReLoad方法的典型用法代码示例。如果您正苦于以下问题:C# LineInfo.ReLoad方法的具体用法?C# LineInfo.ReLoad怎么用?C# LineInfo.ReLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelpers.LineInfo
的用法示例。
在下文中一共展示了LineInfo.ReLoad方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractValue
// object[] values, int index, ForwardReader reader
internal object ExtractValue(LineInfo line)
{
//-> extract only what I need
if (this.mInNewLine == true)
{
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.");
}
ExtractedInfo 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);
// }
}
示例2: ExtractFieldValue
/// <summary>
/// Get the data out of the records
/// </summary>
/// <param name="line">Line handler containing text</param>
/// <returns></returns>
internal object ExtractFieldValue(LineInfo line)
{
//-> extract only what I need
if (InNewLine) {
// Any trailing characters, terminate
if (line.EmptyFromPos() == false) {
throw new BadUsageException(line,
"Text '" + line.CurrentString +
"' found before the new line of the field: " + FieldInfo.Name +
" (this is not allowed when you use [FieldInNewLine])");
}
line.ReLoad(line.mReader.ReadNextLine());
if (line.mLineStr == null) {
throw new BadUsageException(line,
"End of stream found parsing the field " + FieldInfo.Name +
". Please check the class record.");
}
}
if (IsArray == false) {
ExtractedInfo info = ExtractFieldString(line);
if (info.mCustomExtractedString == null)
line.mCurrentPos = info.ExtractedTo + 1;
line.mCurrentPos += CharsToDiscard; //total;
if (Discarded)
return GetDiscardedNullValue();
else
return AssignFromString(info, line).Value;
}
else {
if (ArrayMinLength <= 0)
ArrayMinLength = 0;
int i = 0;
var res = new ArrayList(Math.Max(ArrayMinLength, 10));
while (line.mCurrentPos - CharsToDiscard < line.mLineStr.Length &&
i < ArrayMaxLength) {
ExtractedInfo info = ExtractFieldString(line);
if (info.mCustomExtractedString == null)
line.mCurrentPos = info.ExtractedTo + 1;
line.mCurrentPos += CharsToDiscard;
try {
var value = AssignFromString(info, line);
if (value.NullValueUsed &&
i == 0 &&
line.IsEOL())
break;
res.Add(value.Value);
}
catch (NullValueNotFoundException) {
if (i == 0)
break;
else
throw;
}
i++;
}
if (res.Count < ArrayMinLength) {
throw new InvalidOperationException(
string.Format(
"Line: {0} Column: {1} Field: {2}. The array has only {3} values, less than the minimum length of {4}",
line.mReader.LineNumber.ToString(),
line.mCurrentPos.ToString(),
FieldInfo.Name,
res.Count,
ArrayMinLength));
}
else if (IsLast && line.IsEOL() == false) {
throw new InvalidOperationException(
string.Format(
"Line: {0} Column: {1} Field: {2}. The array has more values than the maximum length of {3}",
line.mReader.LineNumber,
line.mCurrentPos,
FieldInfo.Name,
ArrayMaxLength));
}
// TODO: is there a reason we go through all the array processing then discard it
if (Discarded)
return null;
else
return res.ToArray(ArrayType);
}
//.........这里部分代码省略.........
示例3: ExtractFieldValue
internal object ExtractFieldValue(LineInfo line)
{
//-> extract only what I need
if (InNewLine)
{
if (line.EmptyFromPos() == false)
throw new BadUsageException(line, "Text '" + line.CurrentString +
"' found before the new line of the field: " + FieldInfo.Name +
" (this is not allowed when you use [FieldInNewLine])");
line.ReLoad(line.mReader.ReadNextLine());
if (line.mLineStr == null)
throw new BadUsageException(line, "End of stream found parsing the field " + FieldInfo.Name +
". Please check the class record.");
}
if (IsArray == false)
{
ExtractedInfo info = ExtractFieldString(line);
if (info.mCustomExtractedString == null)
line.mCurrentPos = info.ExtractedTo + 1;
line.mCurrentPos += CharsToDiscard; //total;
return AssignFromString(info, line);
}
else
{
if (ArrayMinLength <= 0)
ArrayMinLength = 0;
int i = 0;
var res = new ArrayList(Math.Max(ArrayMinLength, 10));
while (line.mCurrentPos - CharsToDiscard < line.mLine.Length && i < ArrayMaxLength)
{
ExtractedInfo info = ExtractFieldString(line);
if (info.mCustomExtractedString == null)
line.mCurrentPos = info.ExtractedTo + 1;
line.mCurrentPos += CharsToDiscard;
res.Add(AssignFromString(info, line));
i++;
}
if (res.Count < ArrayMinLength)
throw new InvalidOperationException(string.Format("Line: {0} Column: {1} Field: {2}. The array has only {3} values, less than the minimum length of {4}", line.mReader.LineNumber.ToString(), line.mCurrentPos.ToString(), FieldInfo.Name, res.Count, ArrayMinLength));
else if (IsLast && line.IsEOL() == false)
throw new InvalidOperationException(string.Format("Line: {0} Column: {1} Field: {2}. The array has more values than the maximum length of {3}", line.mReader.LineNumber, line.mCurrentPos, FieldInfo.Name, ArrayMaxLength));
return res.ToArray(ArrayType);
}
}