【优化】如果枚举类包含value为0的枚举项,允许excel中列限定模式下为空取默认值

main
walon 2022-01-26 11:25:46 +08:00
parent c20505aea3
commit 1acaac5b87
1 changed files with 9 additions and 2 deletions

View File

@ -196,9 +196,16 @@ namespace Luban.Job.Cfg.DataCreators
{
return null;
}
if (x == null)
if (CheckDefault(x))
{
throw new InvalidExcelDataException($"枚举值不能为空");
if (type.DefineEnum.HasZeroValueItem)
{
return new DEnum(type, "0");
}
else
{
throw new InvalidExcelDataException($"枚举类:'{type.DefineEnum.FullName}' 没有value为0的枚举项, 不支持默认值");
}
}
return new DEnum(type, x.ToString());
}