【优化】convert_xlsx格式,对于复合字段,如果未指定sep,则默认使用|

main
walon 2021-11-16 19:13:21 +08:00
parent 8e8fe68fd0
commit e9f608a238
1 changed files with 14 additions and 6 deletions

View File

@ -97,6 +97,10 @@ namespace Luban.Job.Cfg.DataConverts
{
sep = type.Type.Sep;
}
else if (string.IsNullOrWhiteSpace(sep))
{
sep = "|";
}
var sb = new List<string>();
if (type.Type.IsAbstractType)
{
@ -133,33 +137,37 @@ namespace Luban.Job.Cfg.DataConverts
public string Accept(DArray type, string sep)
{
if (string.IsNullOrEmpty(sep) && type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
if (string.IsNullOrEmpty(sep))
{
sep = ";";
sep = type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? ";" : "|";
}
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
}
public string Accept(DList type, string sep)
{
if (string.IsNullOrEmpty(sep) && type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
if (string.IsNullOrEmpty(sep))
{
sep = ",";
sep = type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? ";" : "|";
}
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
}
public string Accept(DSet type, string sep)
{
if (string.IsNullOrEmpty(sep) && type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
if (string.IsNullOrEmpty(sep))
{
sep = ",";
sep = type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? ";" : "|";
}
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
}
public string Accept(DMap type, string sep)
{
if (string.IsNullOrEmpty(sep))
{
sep = "|";
}
return string.Join(sep, type.Datas.Select(d => $"{d.Key.Apply(this, sep)}{sep}{d.Value.Apply(this, sep)}"));
}