【修复】修复上次调整sep机制引起的读取简单数据列表只读到第一个字段的问题

main
walon 2022-01-29 14:54:15 +08:00
parent b3457da8d2
commit 54e1955112
2 changed files with 22 additions and 3 deletions

View File

@ -422,7 +422,8 @@ namespace Luban.Job.Cfg.DataCreators
string sep = type.GetTag("sep"); string sep = type.GetTag("sep");
if (string.IsNullOrEmpty(sep) && type.ElementType != null && type.ElementType.Apply(IsNotSepTypeVisitor.Ins)) if (string.IsNullOrEmpty(sep) && type.ElementType != null && type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
{ {
sep = DataUtil.SimpleContainerSep; // 如果是array,list,set并且它们的elementType不包含',;|'则自动添加sep分割。这是一个方便策划的优化
return stream.CreateAutoSepStream(DataUtil.SimpleContainerSep);
} }
if (!string.IsNullOrEmpty(sep) && !stream.TryReadEOF()) if (!string.IsNullOrEmpty(sep) && !stream.TryReadEOF())

View File

@ -265,10 +265,10 @@ namespace Luban.Job.Cfg.DataSources.Excel
int oldIndex = _curIndex; int oldIndex = _curIndex;
while (_curIndex <= _toIndex) while (_curIndex <= _toIndex)
{ {
var value = _datas[_curIndex++].Value?.ToString(); var value = _datas[_curIndex++].Value;
if (!IsSkip(value)) if (!IsSkip(value))
{ {
if (value == END_OF_LIST) if (value is string s && s == END_OF_LIST)
{ {
LastReadIndex = _curIndex - 1; LastReadIndex = _curIndex - 1;
return true; return true;
@ -284,5 +284,23 @@ namespace Luban.Job.Cfg.DataSources.Excel
_curIndex = oldIndex; _curIndex = oldIndex;
return true; return true;
} }
internal ExcelStream CreateAutoSepStream(string simpleContainerSep)
{
int startIndex = _curIndex;
while (_curIndex <= _toIndex)
{
var value = _datas[_curIndex++].Value;
if (!IsSkip(value))
{
if (value is string s && s == END_OF_LIST)
{
break;
}
}
}
LastReadIndex = _curIndex - 1;
return new ExcelStream(_datas, startIndex, LastReadIndex, simpleContainerSep, "");
}
} }
} }