diff --git a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs index a134c73..3ac271d 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs @@ -262,7 +262,7 @@ namespace Luban.Job.Cfg.DataCreators public DType Accept(TText type, ExcelStream x) { - x = SepIfNeed(type, x); + //x = SepIfNeed(type, x); string key = ParseString(x.Read()); if (key == null) { @@ -313,23 +313,26 @@ namespace Luban.Job.Cfg.DataCreators 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 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) { var originBean = (DefBean)type.Bean; - x = SepIfNeed(type, x); + if (!string.IsNullOrEmpty(originBean.Sep)) + { + x = new ExcelStream(x.ReadCell(), originBean.Sep); + } if (originBean.IsAbstractType) { @@ -382,22 +385,22 @@ namespace Luban.Job.Cfg.DataCreators public DType Accept(TArray type, ExcelStream x) { - return new DArray(type, ReadList(type.ElementType, SepIfNeed(type, x))); + return new DArray(type, ReadList(type.ElementType, x)); } public DType Accept(TList type, ExcelStream x) { - return new DList(type, ReadList(type.ElementType, SepIfNeed(type, x))); + return new DList(type, ReadList(type.ElementType, x)); } public DType Accept(TSet type, ExcelStream x) { - return new DSet(type, ReadList(type.ElementType, SepIfNeed(type, x))); + return new DSet(type, ReadList(type.ElementType, x)); } public DType Accept(TMap type, ExcelStream x) { - x = SepIfNeed(type, x); + //x = SepIfNeed(type, x); var datas = new Dictionary(); while (!x.TryReadEOF()) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs index fa6475b..79874bb 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs @@ -305,7 +305,7 @@ namespace Luban.Job.Cfg.DataCreators public DType Accept(TBean type, Sheet sheet, TitleRow row) { - string sep = DataUtil.GetSep(type); + //string sep = DataUtil.GetSep(type); if (row.Row != null) { @@ -367,7 +367,7 @@ namespace Luban.Job.Cfg.DataCreators } else if (row.Elements != null) { - var s = row.AsMultiRowConcatElements(sep); + var s = row.AsMultiRowConcatElements(); return type.Apply(ExcelStreamDataCreator.Ins, s); } else @@ -401,16 +401,16 @@ namespace Luban.Job.Cfg.DataCreators public DType Accept(TArray type, Sheet sheet, TitleRow row) { - string sep = DataUtil.GetSep(type); + //string sep = DataUtil.GetSep(type); if (row.Row != null) { - var s = row.AsStream(sep); + var s = row.AsStream(DataUtil.GetTypeSep(type.ElementType)); return new DArray(type, ReadList(type.ElementType, s)); } else if (row.Rows != null) { - var s = row.AsMultiRowStream(sep); + var s = row.AsMultiRowStream(DataUtil.GetTypeSep(type.ElementType)); return new DArray(type, ReadList(type.ElementType, s)); } else if (row.Fields != null) @@ -429,16 +429,14 @@ namespace Luban.Job.Cfg.DataCreators public DType Accept(TList type, Sheet sheet, TitleRow row) { - string sep = DataUtil.GetSep(type); - if (row.Row != null) { - var s = row.AsStream(sep); + var s = row.AsStream(DataUtil.GetTypeSep(type.ElementType)); return new DList(type, ReadList(type.ElementType, s)); } else if (row.Rows != null) { - var s = row.AsMultiRowStream(sep); + var s = row.AsMultiRowStream(DataUtil.GetTypeSep(type.ElementType)); return new DList(type, ReadList(type.ElementType, s)); } else if (row.Fields != null) @@ -457,16 +455,14 @@ namespace Luban.Job.Cfg.DataCreators public DType Accept(TSet type, Sheet sheet, TitleRow row) { - string sep = DataUtil.GetSep(type); - if (row.Row != null) { - var s = row.AsStream(sep); + var s = row.AsStream(DataUtil.GetTypeSep(type.ElementType)); return new DSet(type, ReadList(type.ElementType, s)); } else if (row.Rows != null) { - var s = row.AsMultiRowStream(sep); + var s = row.AsMultiRowStream(DataUtil.GetTypeSep(type.ElementType)); return new DSet(type, ReadList(type.ElementType, s)); } else if (row.Fields != null) diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs index 4636497..672e2bb 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs @@ -151,10 +151,9 @@ namespace Luban.Job.Cfg.DataSources.Excel return new ExcelStream(Rows, SelfTitle.FromIndex, SelfTitle.ToIndex, sep, SelfTitle.Default); } - public ExcelStream AsMultiRowConcatElements(string sep) + public ExcelStream AsMultiRowConcatElements() { - sep = string.IsNullOrEmpty(sep) ? SelfTitle.Sep : sep; - return new ExcelStream(Elements.Select(e => e.Row).ToList(), SelfTitle.FromIndex, SelfTitle.ToIndex, sep, SelfTitle.Default); + return new ExcelStream(Elements.Select(e => e.Row).ToList(), SelfTitle.FromIndex, SelfTitle.ToIndex, SelfTitle.Sep, SelfTitle.Default); } } } diff --git a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs index 3019cd3..e4a57c7 100644 --- a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs +++ b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs @@ -139,7 +139,7 @@ namespace Luban.Job.Cfg.Utils return tags.Count > 0 ? tags : null; } - const string SimpleContainerSep = ",;"; + public const string SimpleContainerSep = ",;"; public static string GetSep(TType type) { @@ -158,6 +158,17 @@ namespace Luban.Job.Cfg.Utils } } + public static string GetTypeSep(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 a, List b) { if (a.Count == b.Count)