【特性】支持为容器类型自身及key,value类型单独指定属性(例如 map,(int&ref=test),(int&path=unity)&tag_of_map=xxx)
parent
08720156e8
commit
06467344a5
|
|
@ -8,28 +8,9 @@ using Luban.Job.Common.Types;
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Luban.Job.Cfg.DataCreators
|
||||
{
|
||||
class InvalidExcelDataException : Exception
|
||||
{
|
||||
public InvalidExcelDataException()
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidExcelDataException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidExcelDataException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected InvalidExcelDataException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class ExcelStreamDataCreator : ITypeFuncVisitor<ExcelStream, DType>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Luban.Job.Cfg.DataCreators
|
||||
{
|
||||
class InvalidExcelDataException : Exception
|
||||
{
|
||||
public InvalidExcelDataException()
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidExcelDataException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidExcelDataException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected InvalidExcelDataException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -73,29 +73,29 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<(DefTypeBase, bool), TType> cacheDefTTypes = new Dictionary<(DefTypeBase, bool), TType>();
|
||||
private readonly Dictionary<(DefTypeBase, bool), TType> _cacheDefTTypes = new Dictionary<(DefTypeBase, bool), TType>();
|
||||
|
||||
protected TType GetOrCreateTEnum(DefEnum defType, bool nullable)
|
||||
{
|
||||
if (cacheDefTTypes.TryGetValue((defType, nullable), out var t))
|
||||
if (_cacheDefTTypes.TryGetValue((defType, nullable), out var t))
|
||||
{
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cacheDefTTypes[(defType, nullable)] = TEnum.Create(nullable, defType);
|
||||
return _cacheDefTTypes[(defType, nullable)] = TEnum.Create(nullable, defType);
|
||||
}
|
||||
}
|
||||
|
||||
protected TType GetOrCreateTBean(DefTypeBase defType, bool nullable)
|
||||
{
|
||||
if (cacheDefTTypes.TryGetValue((defType, nullable), out var t))
|
||||
if (_cacheDefTTypes.TryGetValue((defType, nullable), out var t))
|
||||
{
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cacheDefTTypes[(defType, nullable)] = TBean.Create(nullable, (DefBeanBase)defType);
|
||||
return _cacheDefTTypes[(defType, nullable)] = TBean.Create(nullable, (DefBeanBase)defType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +137,18 @@ namespace Luban.Job.Common.Defs
|
|||
protected TType CreateNotContainerType(string module, string rawType)
|
||||
{
|
||||
bool nullable;
|
||||
// 去掉 rawType 两侧的匹配的 ()
|
||||
while (rawType.Length > 0 && rawType[0] == '(')
|
||||
{
|
||||
if (rawType[rawType.Length - 1] == ')')
|
||||
{
|
||||
rawType = rawType.Substring(1, rawType.Length - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"type:{rawType} brace not match");
|
||||
}
|
||||
}
|
||||
var (type, tags) = DefUtil.ParseType(rawType);
|
||||
|
||||
#if !LUBAN_LITE
|
||||
|
|
|
|||
|
|
@ -44,11 +44,25 @@ namespace Luban.Job.Common.Utils
|
|||
}
|
||||
else
|
||||
{
|
||||
#if !LUBAN_LITE
|
||||
return (s[..sepIndex], ParseAttrs(s[(sepIndex + 1)..]));
|
||||
#else
|
||||
return (s.Substring(0, sepIndex), ParseAttrs(s.Substring(sepIndex + 1)));
|
||||
#endif
|
||||
int braceDepth = 0;
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
var c = s[i];
|
||||
if (c == '(')
|
||||
{
|
||||
++braceDepth;
|
||||
}
|
||||
else if (c == ')')
|
||||
{
|
||||
--braceDepth;
|
||||
}
|
||||
|
||||
if (braceDepth == 0 && (c == '#' || c == '&' || c == '|'))
|
||||
{
|
||||
return (s.Substring(0, i), ParseAttrs(s.Substring(i + 1)));
|
||||
}
|
||||
}
|
||||
return (s, new Dictionary<string, string>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue