diff --git a/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs b/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs index 303ad0c..fbeec21 100644 --- a/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs +++ b/src/Luban.Job.Cfg/Source/Defs/CfgDefLoader.cs @@ -339,7 +339,7 @@ namespace Luban.Job.Cfg.Defs case "path": case "range": { - cf.Type = cf.Type + "&" + attrs[i]; + cf.Type = cf.Type + "&(" + attrs[i] + ")"; break; } case "group": @@ -665,16 +665,17 @@ namespace Luban.Job.Cfg.Defs { ValidAttrKeys(defineFile, e, _fieldOptionalAttrs, _fieldRequireAttrs); - string refStr = XmlUtil.GetOptionalAttribute(e, "ref"); string typeStr = XmlUtil.GetRequiredAttribute(e, "type"); + + string refStr = XmlUtil.GetOptionalAttribute(e, "ref"); if (!string.IsNullOrWhiteSpace(refStr)) { - typeStr = typeStr + "&ref=" + refStr; + typeStr = typeStr + "&(ref=" + refStr + ")"; } string pathStr = XmlUtil.GetOptionalAttribute(e, "path"); if (!string.IsNullOrWhiteSpace(pathStr)) { - typeStr = typeStr + "&path=" + pathStr; + typeStr = typeStr + "&(path=" + pathStr + ")"; } return CreateField(defineFile, XmlUtil.GetRequiredAttribute(e, "name"), diff --git a/src/Luban.Job.Cfg/Source/Validators/PathValidator.cs b/src/Luban.Job.Cfg/Source/Validators/PathValidator.cs index badbf0d..84a9167 100644 --- a/src/Luban.Job.Cfg/Source/Validators/PathValidator.cs +++ b/src/Luban.Job.Cfg/Source/Validators/PathValidator.cs @@ -2,6 +2,7 @@ using Luban.Job.Cfg.Datas; using Luban.Job.Cfg.Defs; using Luban.Job.Common.Defs; using Luban.Job.Common.Types; +using Luban.Job.Common.Utils; using System; using System.Collections.Generic; using System.Text.RegularExpressions; @@ -163,7 +164,7 @@ namespace Luban.Job.Cfg.Validators public PathValidator(TType type, string pathPattern) { Type = type; - this.RawPattern = pathPattern; + this.RawPattern = DefUtil.TrimBracePairs(pathPattern); } public void Validate(ValidatorContext ctx, TType type, DType data) diff --git a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs index b40e5e8..51edf62 100644 --- a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs +++ b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs @@ -1,8 +1,10 @@ using Luban.Job.Cfg.Datas; using Luban.Job.Cfg.DataVisitors; using Luban.Job.Cfg.Defs; +using Luban.Job.Cfg.Utils; using Luban.Job.Common.Defs; using Luban.Job.Common.Types; +using Luban.Job.Common.Utils; using System; using System.Collections.Generic; using System.Linq; @@ -31,7 +33,7 @@ namespace Luban.Job.Cfg.Validators public RefValidator(TType type, string tablesStr) { Type = type; - this.Tables = new List(tablesStr.Split(',')); + this.Tables = new List(DefUtil.TrimBracePairs(tablesStr).Split(',')); } public void Validate(ValidatorContext ctx, TType type, DType key) diff --git a/src/Luban.Job.Cfg/Source/Validators/SetValidator.cs b/src/Luban.Job.Cfg/Source/Validators/SetValidator.cs index bf84466..b4f4728 100644 --- a/src/Luban.Job.Cfg/Source/Validators/SetValidator.cs +++ b/src/Luban.Job.Cfg/Source/Validators/SetValidator.cs @@ -2,6 +2,7 @@ using Luban.Job.Cfg.Datas; using Luban.Job.Common.Defs; using Luban.Job.Common.Types; +using Luban.Job.Common.Utils; using System; using System.Collections.Generic; using System.Linq; @@ -23,7 +24,7 @@ namespace Luban.Job.Cfg.Validators { _type = ttype; _datas = new HashSet(); - _valueSetStr = param; + _valueSetStr = DefUtil.TrimBracePairs(param); } public void Compile(DefFieldBase def) diff --git a/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs b/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs index 9ad7906..57f1ddb 100644 --- a/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs +++ b/src/Luban.Job.Common/Source/Defs/DefAssemblyBase.cs @@ -143,7 +143,7 @@ namespace Luban.Job.Common.Defs public TType CreateType(string module, string type) { - int sepIndex = DefUtil.IndexOfIncludeBrace(type, ','); + int sepIndex = DefUtil.IndexOfElementTypeSep(type); if (sepIndex > 0) { string containerTypeAndTags = DefUtil.TrimBracePairs(type.Substring(0, sepIndex)); @@ -232,7 +232,7 @@ namespace Luban.Job.Common.Defs protected TMap CreateMapType(string module, Dictionary tags, string keyValueType, bool isTreeMap) { - int typeSepIndex = DefUtil.IndexOfIncludeBrace(keyValueType, ','); + int typeSepIndex = DefUtil.IndexOfElementTypeSep(keyValueType); if (typeSepIndex <= 0 || typeSepIndex >= keyValueType.Length - 1) { throw new ArgumentException($"invalid map element type:'{keyValueType}'"); diff --git a/src/Luban.Job.Common/Source/Utils/DefUtil.cs b/src/Luban.Job.Common/Source/Utils/DefUtil.cs index ade78c7..62cbfd4 100644 --- a/src/Luban.Job.Common/Source/Utils/DefUtil.cs +++ b/src/Luban.Job.Common/Source/Utils/DefUtil.cs @@ -39,7 +39,7 @@ namespace Luban.Job.Common.Utils return am; } - public static int IndexOfIncludeBrace(string s, char sep) + public static int IndexOfElementTypeSep(string s) { int braceDepth = 0; for (int i = 0; i < s.Length; i++) @@ -54,7 +54,7 @@ namespace Luban.Job.Common.Utils --braceDepth; } - if (braceDepth == 0 && (c == sep)) + if (braceDepth == 0 && (c == ',' || c == ';')) { return i; }