diff --git a/README.md b/README.md
index da082b6..cda50a6 100644
--- a/README.md
+++ b/README.md
@@ -158,7 +158,16 @@ array与list类型都能表示列表,它们区别在于array生成的代码为
|
2 |
-2,4 |
+2;4 |
+3 | 4 | 5 | |
+aaaa|bbbb|cccc |
+aaa | bbb | ccc |
+
+
+
+ |
+3 |
+2|4|6 |
3 | 4 | 5 | 6 |
aaaa|bbbb|cccc |
aaa | bbb | ccc |
diff --git a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs
index 79874bb..bbc1b35 100644
--- a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs
+++ b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs
@@ -481,7 +481,7 @@ namespace Luban.Job.Cfg.DataCreators
public DType Accept(TMap type, Sheet sheet, TitleRow row)
{
- string sep = DataUtil.GetSep(type);
+ string sep = "";
if (row.Row != null)
{
diff --git a/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs b/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs
index a1ed49d..59335ee 100644
--- a/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs
+++ b/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs
@@ -418,7 +418,7 @@ namespace Luban.Job.Cfg.Defs
defTableRecordType.PreCompile();
defTableRecordType.Compile();
defTableRecordType.PostCompile();
- var tableRecordType = TBean.Create(false, defTableRecordType);
+ var tableRecordType = TBean.Create(false, defTableRecordType, null);
foreach (var file in inputFileInfos)
{
@@ -485,7 +485,7 @@ namespace Luban.Job.Cfg.Defs
defTableRecordType.PreCompile();
defTableRecordType.Compile();
defTableRecordType.PostCompile();
- var tableRecordType = TBean.Create(false, defTableRecordType);
+ var tableRecordType = TBean.Create(false, defTableRecordType, null);
foreach (var file in inputFileInfos)
{
@@ -592,7 +592,7 @@ namespace Luban.Job.Cfg.Defs
defTableRecordType.PreCompile();
defTableRecordType.Compile();
defTableRecordType.PostCompile();
- var tableRecordType = TBean.Create(false, defTableRecordType);
+ var tableRecordType = TBean.Create(false, defTableRecordType, null);
foreach (var file in inputFileInfos)
{
diff --git a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs
index e4a57c7..1b4f3f3 100644
--- a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs
+++ b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs
@@ -139,23 +139,15 @@ namespace Luban.Job.Cfg.Utils
return tags.Count > 0 ? tags : null;
}
- public const string SimpleContainerSep = ",;";
+ public const string SimpleContainerSep = ",;|";
- public static string GetSep(TType type)
+ public static string GetBeanSep(TBean type)
{
-
if (type.Tags != null && type.Tags.TryGetValue("sep", out var s) && !string.IsNullOrWhiteSpace(s))
{
return s;
}
- switch (type)
- {
- case TBean tb: return (tb.Bean as DefBean).Sep;
- case TArray ta: return ta.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? SimpleContainerSep : "";
- case TList ta: return ta.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? SimpleContainerSep : "";
- case TSet ta: return ta.ElementType.Apply(IsNotSepTypeVisitor.Ins) ? SimpleContainerSep : "";
- default: return "";
- }
+ return ((DefBean)type.Bean).Sep;
}
public static string GetTypeSep(TType type)
diff --git a/src/Luban.Job.Cfg/Source/l10n/TextTable.cs b/src/Luban.Job.Cfg/Source/l10n/TextTable.cs
index 089cb96..64e4f83 100644
--- a/src/Luban.Job.Cfg/Source/l10n/TextTable.cs
+++ b/src/Luban.Job.Cfg/Source/l10n/TextTable.cs
@@ -47,7 +47,7 @@ namespace Luban.Job.Cfg.l10n
defTextRowType.PreCompile();
defTextRowType.Compile();
defTextRowType.PostCompile();
- _textRowType = TBean.Create(false, defTextRowType);
+ _textRowType = TBean.Create(false, defTextRowType, null);
}
public void AddText(string key, string text)
diff --git a/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs b/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs
index b17835d..b27624e 100644
--- a/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs
+++ b/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs
@@ -87,37 +87,51 @@ namespace Luban.Job.Common.Defs
private readonly Dictionary<(DefTypeBase, bool), TType> _cacheDefTTypes = new Dictionary<(DefTypeBase, bool), TType>();
- protected TType GetOrCreateTEnum(DefEnum defType, bool nullable)
+ protected TType GetOrCreateTEnum(DefEnum defType, bool nullable, Dictionary tags)
{
- if (_cacheDefTTypes.TryGetValue((defType, nullable), out var t))
+ if (tags == null || tags.Count == 0)
{
- return t;
+ if (_cacheDefTTypes.TryGetValue((defType, nullable), out var t))
+ {
+ return t;
+ }
+ else
+ {
+ return _cacheDefTTypes[(defType, nullable)] = TEnum.Create(nullable, defType, tags);
+ }
}
else
{
- return _cacheDefTTypes[(defType, nullable)] = TEnum.Create(nullable, defType);
+ return TEnum.Create(nullable, defType, tags); ;
}
}
- protected TType GetOrCreateTBean(DefTypeBase defType, bool nullable)
+ protected TType GetOrCreateTBean(DefTypeBase defType, bool nullable, Dictionary tags)
{
- if (_cacheDefTTypes.TryGetValue((defType, nullable), out var t))
+ if (tags == null || tags.Count == 0)
{
- return t;
+ if (_cacheDefTTypes.TryGetValue((defType, nullable), out var t))
+ {
+ return t;
+ }
+ else
+ {
+ return _cacheDefTTypes[(defType, nullable)] = TBean.Create(nullable, (DefBeanBase)defType, tags);
+ }
}
else
{
- return _cacheDefTTypes[(defType, nullable)] = TBean.Create(nullable, (DefBeanBase)defType);
+ return TBean.Create(nullable, (DefBeanBase)defType, tags);
}
}
- public TType GetDefTType(string module, string type, bool nullable)
+ public TType GetDefTType(string module, string type, bool nullable, Dictionary tags)
{
var defType = GetDefType(module, type);
switch (defType)
{
- case DefBeanBase d: return GetOrCreateTBean(d, nullable);
- case DefEnum d: return GetOrCreateTEnum(d, nullable);
+ case DefBeanBase d: return GetOrCreateTBean(d, nullable, tags);
+ case DefEnum d: return GetOrCreateTEnum(d, nullable, tags);
default: return null;
}
}
@@ -202,7 +216,7 @@ namespace Luban.Job.Common.Defs
case "datetime": return SupportDatetimeType ? TDateTime.Create(nullable, tags) : throw new NotSupportedException($"只有配置支持datetime数据类型");
default:
{
- var dtype = GetDefTType(module, type, nullable);
+ var dtype = GetDefTType(module, type, nullable, tags);
if (dtype != null)
{
return dtype;
diff --git a/src/Luban.Job.Common/Source/Types/TBean.cs b/src/Luban.Job.Common/Source/Types/TBean.cs
index ff1e1f3..e8e402a 100644
--- a/src/Luban.Job.Common/Source/Types/TBean.cs
+++ b/src/Luban.Job.Common/Source/Types/TBean.cs
@@ -1,5 +1,6 @@
using Luban.Job.Common.Defs;
using Luban.Job.Common.TypeVisitors;
+using Luban.Job.Common.Utils;
using System;
using System.Collections.Generic;
@@ -7,9 +8,10 @@ namespace Luban.Job.Common.Types
{
public class TBean : TType
{
- public static TBean Create(bool isNullable, DefBeanBase defBean)
+ public static TBean Create(bool isNullable, DefBeanBase defBean, Dictionary tags)
{
- return new TBean(isNullable, defBean.Tags, defBean);
+ // TODO
+ return new TBean(isNullable, DefUtil.MergeTags(defBean.Tags, tags), defBean);
}
public DefBeanBase Bean { get; set; }
diff --git a/src/Luban.Job.Common/Source/Types/TEnum.cs b/src/Luban.Job.Common/Source/Types/TEnum.cs
index 298b49f..cda5570 100644
--- a/src/Luban.Job.Common/Source/Types/TEnum.cs
+++ b/src/Luban.Job.Common/Source/Types/TEnum.cs
@@ -1,5 +1,6 @@
using Luban.Job.Common.Defs;
using Luban.Job.Common.TypeVisitors;
+using Luban.Job.Common.Utils;
using System;
using System.Collections.Generic;
@@ -7,9 +8,9 @@ namespace Luban.Job.Common.Types
{
public class TEnum : TType
{
- public static TEnum Create(bool isNullable, DefEnum defEnum)
+ public static TEnum Create(bool isNullable, DefEnum defEnum, Dictionary tags)
{
- return new TEnum(isNullable, defEnum.Tags, defEnum);
+ return new TEnum(isNullable, DefUtil.MergeTags(defEnum.Tags, tags), defEnum);
}
public DefEnum DefineEnum { get; }
diff --git a/src/Luban.Job.Common/Source/Utils/DefUtil.cs b/src/Luban.Job.Common/Source/Utils/DefUtil.cs
index fd090dd..956df66 100644
--- a/src/Luban.Job.Common/Source/Utils/DefUtil.cs
+++ b/src/Luban.Job.Common/Source/Utils/DefUtil.cs
@@ -1,4 +1,5 @@
-using System;
+using Bright.Collections;
+using System;
using System.Collections.Generic;
namespace Luban.Job.Common.Utils
@@ -123,7 +124,35 @@ namespace Luban.Job.Common.Utils
public static bool IsNormalFieldName(string name)
{
- return !name.StartsWith("__");
+ return !name.StartsWith("__") && !name.StartsWith("#");
+ }
+
+ public static Dictionary MergeTags(Dictionary tags1, Dictionary tags2)
+ {
+ if (tags2 != null && tags2.Count > 0)
+ {
+ if (tags1 != null)
+ {
+ if (tags1.Count == 0)
+ {
+ return tags2;
+ }
+ else
+ {
+ var result = new Dictionary(tags1);
+ result.AddAll(tags2);
+ return result;
+ }
+ }
+ else
+ {
+ return tags2;
+ }
+ }
+ else
+ {
+ return tags1;
+ }
}
}
}