【调整】移除对简单容器类型如"list,int"之类自动sep的支持,简化规则
parent
0122d97071
commit
66e07830d0
|
|
@ -246,28 +246,19 @@ namespace Luban.Job.Cfg.DataConverts
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Accept(TArray type, Title title, int column)
|
public void Accept(TArray type, Title title, int column)
|
||||||
{
|
|
||||||
if (!type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
|
||||||
{
|
{
|
||||||
title.Tags.TryAdd("sep", "|");
|
title.Tags.TryAdd("sep", "|");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Accept(TList type, Title title, int column)
|
public void Accept(TList type, Title title, int column)
|
||||||
{
|
|
||||||
if (!type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
|
||||||
{
|
{
|
||||||
title.Tags.TryAdd("sep", "|");
|
title.Tags.TryAdd("sep", "|");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Accept(TSet type, Title title, int column)
|
public void Accept(TSet type, Title title, int column)
|
||||||
{
|
|
||||||
if (!type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
|
||||||
{
|
{
|
||||||
title.Tags.TryAdd("sep", "|");
|
title.Tags.TryAdd("sep", "|");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Accept(TMap type, Title title, int column)
|
public void Accept(TMap type, Title title, int column)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Luban.Job.Cfg.DataConverts
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sep))
|
if (string.IsNullOrEmpty(sep))
|
||||||
{
|
{
|
||||||
sep = type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? ";" : "|";
|
sep = "|";
|
||||||
}
|
}
|
||||||
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +148,7 @@ namespace Luban.Job.Cfg.DataConverts
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sep))
|
if (string.IsNullOrEmpty(sep))
|
||||||
{
|
{
|
||||||
sep = type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? ";" : "|";
|
sep = "|";
|
||||||
}
|
}
|
||||||
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +157,7 @@ namespace Luban.Job.Cfg.DataConverts
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sep))
|
if (string.IsNullOrEmpty(sep))
|
||||||
{
|
{
|
||||||
sep = type.Type.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? ";" : "|";
|
sep = "|";
|
||||||
}
|
}
|
||||||
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
return string.Join(sep, type.Datas.Select(d => d.Apply(this, sep)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -360,19 +360,6 @@ namespace Luban.Job.Cfg.DataCreators
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static ExcelStream SepIfNeed(TType type, ExcelStream stream)
|
|
||||||
//{
|
|
||||||
// string sep = DataUtil.GetSep(type);
|
|
||||||
// if (!string.IsNullOrEmpty(sep))
|
|
||||||
// {
|
|
||||||
// return new ExcelStream(stream.ReadCell(), sep);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return stream;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public DType Accept(TBean type, ExcelStream x)
|
public DType Accept(TBean type, ExcelStream x)
|
||||||
{
|
{
|
||||||
var originBean = (DefBean)type.Bean;
|
var originBean = (DefBean)type.Bean;
|
||||||
|
|
@ -420,11 +407,6 @@ namespace Luban.Job.Cfg.DataCreators
|
||||||
private static ExcelStream TrySep(TType type, ExcelStream stream)
|
private static ExcelStream TrySep(TType type, ExcelStream stream)
|
||||||
{
|
{
|
||||||
string sep = type.GetTag("sep");
|
string sep = type.GetTag("sep");
|
||||||
if (string.IsNullOrEmpty(sep) && type.ElementType != null && type.ElementType.Apply(IsNotSepTypeVisitor.Ins))
|
|
||||||
{
|
|
||||||
// 如果是array,list,set,并且它们的elementType不包含',;|',则自动添加sep分割。这是一个方便策划的优化
|
|
||||||
return stream.CreateAutoSepStream(DataUtil.SimpleContainerSep);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(sep) && !stream.TryReadEOF())
|
if (!string.IsNullOrEmpty(sep) && !stream.TryReadEOF())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
{
|
{
|
||||||
class IsNotSepTypeVisitor : AllTrueVisitor
|
class IsNotSepTypeVisitor : AllTrueVisitor
|
||||||
{
|
{
|
||||||
public static IsNotSepTypeVisitor Ins { get; } = new IsNotSepTypeVisitor();
|
//public static IsNotSepTypeVisitor Ins { get; } = new IsNotSepTypeVisitor();
|
||||||
|
|
||||||
|
|
||||||
public override bool Accept(TString type)
|
public override bool Accept(TString type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ namespace Luban.Job.Cfg.Utils
|
||||||
return rec.Tags != null && rec.Tags.Count > 0 && rec.Tags.Contains(TAG_UNCHECKED);
|
return rec.Tags != null && rec.Tags.Count > 0 && rec.Tags.Contains(TAG_UNCHECKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string SimpleContainerSep = ",;|";
|
//public const string SimpleContainerSep = ",;|";
|
||||||
|
|
||||||
public static string GetBeanSep(TBean type)
|
public static string GetBeanSep(TBean type)
|
||||||
{
|
{
|
||||||
|
|
@ -157,17 +157,6 @@ namespace Luban.Job.Cfg.Utils
|
||||||
return ((DefBean)type.Bean).Sep;
|
return ((DefBean)type.Bean).Sep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCollectionElementTypeSep(TType type)
|
|
||||||
{
|
|
||||||
if (type.Tags != null && type.Tags.TryGetValue("sep", out var s) && !string.IsNullOrWhiteSpace(s))
|
|
||||||
{
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.Apply(IsNotSepTypeVisitor.Ins) ? SimpleContainerSep : "";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsCollectionEqual(List<DType> a, List<DType> b)
|
public static bool IsCollectionEqual(List<DType> a, List<DType> b)
|
||||||
{
|
{
|
||||||
if (a.Count == b.Count)
|
if (a.Count == b.Count)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue