【重构】重构创建TType对象的方式。只允许通过工厂模式创建。
parent
6eb1a0d4f5
commit
2685a4d5d4
|
|
@ -65,6 +65,7 @@ Luban适合有以下需求的开发者:
|
|||
- 支持res资源标记。可以一键导出配置中引用的所有资源列表(icon,ui,assetbundle等等)
|
||||
- 统一了自定义编辑器的配置数据。与Unity和UE4的自定义编辑器良好配合,为编辑器生成合适的加载与保存json配置的的c#(Unity)或c++(UE4)代码。保存的json配置能够被luban识别和处理。
|
||||
- 支持emmylua anntations。生成的lua包含符合emmylua 格式anntations信息。配合emmylua有良好的配置代码提示能力
|
||||
- 灵活的自定义生成能力。可以在不修改代码的情况下使用自定义模板取代默认生成模板。大多数自定义对象支持tags属性,允许通过tags生成特殊内容。
|
||||
- **本地化支持**
|
||||
- 支持时间本地化。datetime类型数据会根据指定的timezone,转换为目标地区该时刻的UTC时间,方便程序使用。
|
||||
- 支持文本静态本地化。导出时所有text类型数据正确替换为最终的本地化字符串。绝大多数的业务功能不再需要运行根据本地化id去查找文本的内容,简化程序员的工作。
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
defTableRecordType.PreCompile();
|
||||
defTableRecordType.Compile();
|
||||
defTableRecordType.PostCompile();
|
||||
var tableRecordType = new TBean(defTableRecordType, false);
|
||||
var tableRecordType = TBean.Create(false, defTableRecordType);
|
||||
|
||||
foreach (var file in inputFileInfos)
|
||||
{
|
||||
|
|
@ -530,7 +530,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
defTableRecordType.PreCompile();
|
||||
defTableRecordType.Compile();
|
||||
defTableRecordType.PostCompile();
|
||||
var tableRecordType = new TBean(defTableRecordType, false);
|
||||
var tableRecordType = TBean.Create(false, defTableRecordType);
|
||||
|
||||
foreach (var file in inputFileInfos)
|
||||
{
|
||||
|
|
@ -643,7 +643,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
defTableRecordType.Compile();
|
||||
defTableRecordType.PostCompile();
|
||||
ass.MarkMultiRows();
|
||||
var tableRecordType = new TBean(defTableRecordType, false);
|
||||
var tableRecordType = TBean.Create(false, defTableRecordType);
|
||||
|
||||
foreach (var file in inputFileInfos)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Luban.Job.Cfg.l10n
|
|||
defTextRowType.PreCompile();
|
||||
defTextRowType.Compile();
|
||||
defTextRowType.PostCompile();
|
||||
_textRowType = new TBean(defTextRowType, false);
|
||||
_textRowType = TBean.Create(false, defTextRowType);
|
||||
}
|
||||
|
||||
public void AddText(string key, string text)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
else
|
||||
{
|
||||
return cacheDefTTypes[(defType, nullable)] = new TEnum(defType, nullable);
|
||||
return cacheDefTTypes[(defType, nullable)] = TEnum.Create(nullable, defType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
else
|
||||
{
|
||||
return cacheDefTTypes[(defType, nullable)] = new TBean((DefBeanBase)defType, nullable);
|
||||
return cacheDefTTypes[(defType, nullable)] = TBean.Create(nullable, (DefBeanBase)defType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,33 +149,33 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
switch (type)
|
||||
{
|
||||
case "bool": return tags == null ? (nullable ? TBool.NullableIns : TBool.Ins) : new TBool(nullable) { Tags = tags };
|
||||
case "bool": return TBool.Create(nullable, tags);
|
||||
case "uint8":
|
||||
case "byte": return tags == null ? (nullable ? TByte.NullableIns : TByte.Ins) : new TByte(nullable) { Tags = tags };
|
||||
case "byte": return TByte.Create(nullable, tags);
|
||||
case "int16":
|
||||
case "short": return tags == null ? (nullable ? TShort.NullableIns : TShort.Ins) : new TShort(nullable) { Tags = tags };
|
||||
case "short": return TShort.Create(nullable, tags);
|
||||
case "fint16":
|
||||
case "fshort": return tags == null ? (nullable ? TFshort.NullableIns : TFshort.Ins) : new TFshort(nullable) { Tags = tags };
|
||||
case "fshort": return TFshort.Create(nullable, tags);
|
||||
case "int32":
|
||||
case "int": return tags == null ? (nullable ? TInt.NullableIns : TInt.Ins) : new TInt(nullable) { Tags = tags };
|
||||
case "int": return TInt.Create(nullable, tags);
|
||||
case "fint32":
|
||||
case "fint": return tags == null ? (nullable ? TFint.NullableIns : TFint.Ins) : new TFint(nullable) { Tags = tags };
|
||||
case "fint": return TFint.Create(nullable, tags);
|
||||
case "int64":
|
||||
case "long": return tags == null ? (nullable ? TLong.NullableIns : TLong.Ins) : new TLong(nullable, false) { Tags = tags };
|
||||
case "bigint": return tags == null ? (nullable ? TLong.NullableBigIns : TLong.BigIns) : new TLong(nullable, true) { Tags = tags };
|
||||
case "long": return TLong.Create(nullable, tags, false);
|
||||
case "bigint": return TLong.Create(nullable, tags, true);
|
||||
case "fint64":
|
||||
case "flong": return tags == null ? (nullable ? TFlong.NullableIns : TFlong.Ins) : new TFlong(nullable) { Tags = tags };
|
||||
case "flong": return TFlong.Create(nullable, tags);
|
||||
case "float32":
|
||||
case "float": return tags == null ? (nullable ? TFloat.NullableIns : TFloat.Ins) : new TFloat(nullable) { Tags = tags };
|
||||
case "float": return TFloat.Create(nullable, tags);
|
||||
case "float64":
|
||||
case "double": return tags == null ? (nullable ? TDouble.NullableIns : TDouble.Ins) : new TDouble(nullable) { Tags = tags };
|
||||
case "bytes": return tags == null ? (nullable ? new TBytes(true) : TBytes.Ins) : new TBytes(false) { Tags = tags };
|
||||
case "string": return tags == null ? (nullable ? TString.NullableIns : TString.Ins) : new TString(nullable) { Tags = tags };
|
||||
case "text": return tags == null ? (nullable ? TText.NullableIns : TText.Ins) : new TText(nullable) { Tags = tags };
|
||||
case "vector2": return tags == null ? (nullable ? TVector2.NullableIns : TVector2.Ins) : new TVector2(nullable) { Tags = tags };
|
||||
case "vector3": return tags == null ? (nullable ? TVector3.NullableIns : TVector3.Ins) : new TVector3(nullable) { Tags = tags };
|
||||
case "vector4": return tags == null ? (nullable ? TVector4.NullableIns : TVector4.Ins) : new TVector4(nullable) { Tags = tags };
|
||||
case "datetime": return SupportDatetimeType ? (tags == null ? (nullable ? TDateTime.NullableIns : TDateTime.Ins) : new TDateTime(nullable) { Tags = tags }) : throw new NotSupportedException($"只有配置支持datetime数据类型");
|
||||
case "double": return TDouble.Create(nullable, tags);
|
||||
case "bytes": return TBytes.Create(nullable, tags);
|
||||
case "string": return TString.Create(nullable, tags);
|
||||
case "text": return TText.Create(nullable, tags);
|
||||
case "vector2": return TVector2.Create(nullable, tags);
|
||||
case "vector3": return TVector3.Create(nullable, tags);
|
||||
case "vector4": return TVector4.Create(nullable, tags);
|
||||
case "datetime": return SupportDatetimeType ? TDateTime.Create(nullable, tags) : throw new NotSupportedException($"只有配置支持datetime数据类型");
|
||||
default:
|
||||
{
|
||||
var dtype = GetDefTType(module, type, nullable);
|
||||
|
|
@ -198,20 +198,20 @@ namespace Luban.Job.Common.Defs
|
|||
{
|
||||
throw new ArgumentException($"invalid map element type:'{keyValueType}'");
|
||||
}
|
||||
return new TMap(CreateNotContainerType(module, elementTypes[0]), CreateNotContainerType(module, elementTypes[1]), isTreeMap);
|
||||
return TMap.Create(false, null, CreateNotContainerType(module, elementTypes[0]), CreateNotContainerType(module, elementTypes[1]), isTreeMap);
|
||||
}
|
||||
|
||||
protected TType CreateContainerType(string module, string containerType, string elementType)
|
||||
{
|
||||
switch (containerType)
|
||||
{
|
||||
case "array": return new TArray(CreateNotContainerType(module, elementType));
|
||||
case "list": return new TList(CreateNotContainerType(module, elementType), false);
|
||||
case "linkedlist": return new TList(CreateNotContainerType(module, elementType), true);
|
||||
case "arraylist": return new TList(CreateNotContainerType(module, elementType), false);
|
||||
case "set": return new TSet(CreateNotContainerType(module, elementType), false);
|
||||
case "hashset": return new TSet(CreateNotContainerType(module, elementType), true);
|
||||
case "treeset": return new TSet(CreateNotContainerType(module, elementType), false);
|
||||
case "array": return TArray.Create(false, null, CreateNotContainerType(module, elementType));
|
||||
case "list": return TList.Create(false, null, CreateNotContainerType(module, elementType), true);
|
||||
case "linkedlist": return TList.Create(false, null, CreateNotContainerType(module, elementType), false);
|
||||
case "arraylist": return TList.Create(false, null, CreateNotContainerType(module, elementType), true);
|
||||
case "set": return TSet.Create(false, null, CreateNotContainerType(module, elementType), false);
|
||||
case "hashset": return TSet.Create(false, null, CreateNotContainerType(module, elementType), false);
|
||||
case "treeset": return TSet.Create(false, null, CreateNotContainerType(module, elementType), true);
|
||||
case "map": return CreateMapType(module, elementType, false);
|
||||
case "treemap": return CreateMapType(module, elementType, true);
|
||||
case "hashmap": return CreateMapType(module, elementType, false);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TArray : TType
|
||||
{
|
||||
|
||||
public static TArray Create(bool isNullable, Dictionary<string, string> tags, TType elementType)
|
||||
{
|
||||
return new TArray(isNullable, tags, elementType);
|
||||
}
|
||||
|
||||
public TType ElementType { get; }
|
||||
|
||||
public TArray(TType elementType) : base(false)
|
||||
private TArray(bool isNullable, Dictionary<string, string> tags, TType elementType) : base(isNullable, tags)
|
||||
{
|
||||
ElementType = elementType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,22 @@
|
|||
using Luban.Job.Common.Defs;
|
||||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TBean : TType
|
||||
{
|
||||
public static TBean Create(bool isNullable, DefBeanBase defBean)
|
||||
{
|
||||
return new TBean(isNullable, defBean.Tags, defBean);
|
||||
}
|
||||
|
||||
public DefBeanBase Bean { get; set; }
|
||||
|
||||
public T GetBeanAs<T>() where T : DefBeanBase => (T)Bean;
|
||||
|
||||
public TBean(DefBeanBase defBean, bool isNullable) : base(isNullable)
|
||||
private TBean(bool isNullable, Dictionary<string, string> attrs, DefBeanBase defBean) : base(isNullable, attrs)
|
||||
{
|
||||
this.Bean = defBean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TBool : TType
|
||||
{
|
||||
private static TBool Ins { get; } = new TBool(false, null);
|
||||
|
||||
public static TBool Ins { get; } = new TBool(false);
|
||||
private static TBool NullableIns { get; } = new TBool(true, null);
|
||||
|
||||
public static TBool NullableIns { get; } = new TBool(true);
|
||||
public static TBool Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TBool(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
public TBool(bool isNullable) : base(isNullable)
|
||||
private TBool(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TByte : TType
|
||||
{
|
||||
public static TByte Ins { get; } = new TByte(false);
|
||||
private static TByte Ins { get; } = new TByte(false, null);
|
||||
|
||||
public static TByte NullableIns { get; } = new TByte(true);
|
||||
private static TByte NullableIns { get; } = new TByte(true, null);
|
||||
|
||||
public TByte(bool isNullable) : base(isNullable)
|
||||
public static TByte Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TByte(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TByte(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,26 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TBytes : TType
|
||||
{
|
||||
public static TBytes Ins { get; } = new TBytes(false);
|
||||
private static TBytes Ins { get; } = new TBytes(false, null);
|
||||
|
||||
public TBytes(bool isNullable) : base(isNullable)
|
||||
public static TBytes Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? new TBytes(true, null) : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TBytes(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TBytes(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,28 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TDateTime : TType
|
||||
{
|
||||
public static TDateTime Ins { get; } = new TDateTime(false);
|
||||
private static TDateTime Ins { get; } = new TDateTime(false, null);
|
||||
|
||||
public static TDateTime NullableIns { get; } = new TDateTime(true);
|
||||
private static TDateTime NullableIns { get; } = new TDateTime(true, null);
|
||||
|
||||
public TDateTime(bool isNullable) : base(isNullable)
|
||||
public static TDateTime Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TDateTime(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TDateTime(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TDouble : TType
|
||||
{
|
||||
public static TDouble Ins { get; } = new TDouble(false);
|
||||
private static TDouble Ins { get; } = new TDouble(false, null);
|
||||
|
||||
public static TDouble NullableIns { get; } = new TDouble(true);
|
||||
private static TDouble NullableIns { get; } = new TDouble(true, null);
|
||||
|
||||
public TDouble(bool isNullable) : base(isNullable)
|
||||
public static TDouble Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TDouble(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TDouble(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
using Luban.Job.Common.Defs;
|
||||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TEnum : TType
|
||||
{
|
||||
public static TEnum Create(bool isNullable, DefEnum defEnum)
|
||||
{
|
||||
return new TEnum(isNullable, defEnum.Tags, defEnum);
|
||||
}
|
||||
|
||||
public DefEnum DefineEnum { get; }
|
||||
|
||||
public TEnum(DefEnum defEnum, bool isNullable) : base(isNullable)
|
||||
private TEnum(bool isNullable, Dictionary<string, string> tags, DefEnum defEnum) : base(isNullable, tags)
|
||||
{
|
||||
this.DefineEnum = defEnum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TFint : TType
|
||||
{
|
||||
public static TFint Ins { get; } = new TFint(false);
|
||||
private static TFint Ins { get; } = new TFint(false, null);
|
||||
|
||||
public static TFint NullableIns { get; } = new TFint(true);
|
||||
private static TFint NullableIns { get; } = new TFint(true, null);
|
||||
|
||||
public TFint(bool isNullable) : base(isNullable)
|
||||
public static TFint Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TFint(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TFint(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TFloat : TType
|
||||
{
|
||||
public static TFloat Ins { get; } = new TFloat(false);
|
||||
public static TFloat Ins { get; } = new TFloat(false, null);
|
||||
|
||||
public static TFloat NullableIns { get; } = new TFloat(true);
|
||||
private static TFloat NullableIns { get; } = new TFloat(true, null);
|
||||
|
||||
public TFloat(bool isNullable) : base(isNullable)
|
||||
public static TFloat Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TFloat(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TFloat(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TFlong : TType
|
||||
{
|
||||
public static TFlong Ins { get; } = new TFlong(false);
|
||||
private static TFlong Ins { get; } = new TFlong(false, null);
|
||||
|
||||
public static TFlong NullableIns { get; } = new TFlong(true);
|
||||
private static TFlong NullableIns { get; } = new TFlong(true, null);
|
||||
|
||||
public TFlong(bool isNullable) : base(isNullable)
|
||||
public static TFlong Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TFlong(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TFlong(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TFshort : TType
|
||||
{
|
||||
public static TFshort Ins { get; } = new TFshort(false);
|
||||
private static TFshort Ins { get; } = new TFshort(false, null);
|
||||
|
||||
public static TFshort NullableIns { get; } = new TFshort(true);
|
||||
private static TFshort NullableIns { get; } = new TFshort(true, null);
|
||||
|
||||
public TFshort(bool isNullable) : base(isNullable)
|
||||
public static TFshort Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TFshort(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TFshort(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TInt : TType
|
||||
{
|
||||
public static TInt Ins { get; } = new TInt(false);
|
||||
private static TInt Ins { get; } = new TInt(false, null);
|
||||
|
||||
public static TInt NullableIns { get; } = new TInt(true);
|
||||
private static TInt NullableIns { get; } = new TInt(true, null);
|
||||
|
||||
public TInt(bool isNullable) : base(isNullable)
|
||||
public static TInt Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TInt(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TInt(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TList : TType
|
||||
{
|
||||
public static TList Create(bool isNullable, Dictionary<string, string> tags, TType elementType, bool isArrayList)
|
||||
{
|
||||
return new TList(isNullable, tags, elementType, isArrayList);
|
||||
}
|
||||
|
||||
public TType ElementType { get; }
|
||||
|
||||
public bool IsArrayList { get; }
|
||||
|
||||
public TList(TType elementType, bool isArrayList) : base(false)
|
||||
private TList(bool isNullable, Dictionary<string, string> tags, TType elementType, bool isArrayList) : base(isNullable, tags)
|
||||
{
|
||||
ElementType = elementType;
|
||||
IsArrayList = isArrayList;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,33 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TLong : TType
|
||||
{
|
||||
public static TLong Ins { get; } = new TLong(false, false);
|
||||
private static TLong Ins { get; } = new TLong(false, null, false);
|
||||
|
||||
public static TLong NullableIns { get; } = new TLong(true, false);
|
||||
private static TLong NullableIns { get; } = new TLong(true, null, false);
|
||||
|
||||
public static TLong BigIns { get; } = new TLong(false, true);
|
||||
private static TLong BigIns { get; } = new TLong(false, null, true);
|
||||
|
||||
public static TLong NullableBigIns { get; } = new TLong(true, true);
|
||||
private static TLong NullableBigIns { get; } = new TLong(true, null, true);
|
||||
|
||||
public static TLong Create(bool isNullable, Dictionary<string, string> tags, bool isBigInt)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TLong(isNullable, tags, isBigInt);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBigInt { get; }
|
||||
|
||||
public TLong(bool isNullable, bool isBigInt) : base(isNullable)
|
||||
private TLong(bool isNullable, Dictionary<string, string> tags, bool isBigInt) : base(isNullable, tags)
|
||||
{
|
||||
IsBigInt = isBigInt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TMap : TType
|
||||
{
|
||||
public static TMap Create(bool isNullable, Dictionary<string, string> tags, TType keyType, TType valueType, bool isOrderedMap)
|
||||
{
|
||||
return new TMap(isNullable, tags, keyType, valueType, isOrderedMap);
|
||||
}
|
||||
|
||||
public bool IsMap => true;
|
||||
|
||||
public TType KeyType { get; }
|
||||
|
|
@ -13,7 +19,7 @@ namespace Luban.Job.Common.Types
|
|||
|
||||
public bool IsOrderedMap { get; }
|
||||
|
||||
public TMap(TType keyType, TType valueType, bool isOrderedMap) : base(false)
|
||||
private TMap(bool isNullable, Dictionary<string, string> tags, TType keyType, TType valueType, bool isOrderedMap) : base(isNullable, tags)
|
||||
{
|
||||
KeyType = keyType;
|
||||
ValueType = valueType;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TSet : TType
|
||||
{
|
||||
public static TSet Create(bool isNullable, Dictionary<string, string> tags, TType elementType, bool isOrdered)
|
||||
{
|
||||
return new TSet(isNullable, tags, elementType, isOrdered);
|
||||
}
|
||||
|
||||
public TType ElementType { get; }
|
||||
|
||||
public bool IsOrderSet { get; }
|
||||
|
||||
public TSet(TType elementType, bool isOrderSet) : base(false)
|
||||
private TSet(bool isNullable, Dictionary<string, string> tags, TType elementType, bool isOrderSet) : base(isNullable, tags)
|
||||
{
|
||||
ElementType = elementType;
|
||||
IsOrderSet = isOrderSet;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TShort : TType
|
||||
{
|
||||
public static TShort Ins { get; } = new TShort(false);
|
||||
private static TShort Ins { get; } = new TShort(false, null);
|
||||
|
||||
public static TShort NullableIns { get; } = new TShort(true);
|
||||
private static TShort NullableIns { get; } = new TShort(true, null);
|
||||
|
||||
public TShort(bool isNullable) : base(isNullable)
|
||||
public static TShort Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TShort(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TShort(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TString : TType
|
||||
{
|
||||
public static TString Ins { get; } = new TString(false);
|
||||
private static TString Ins { get; } = new TString(false, null);
|
||||
|
||||
public static TString NullableIns { get; } = new TString(true);
|
||||
private static TString NullableIns { get; } = new TString(true, null);
|
||||
|
||||
public TString(bool isNullable) : base(isNullable)
|
||||
public static TString Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TString(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TString(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
|
|
@ -6,11 +7,23 @@ namespace Luban.Job.Common.Types
|
|||
{
|
||||
public const string L10N_FIELD_SUFFIX = "_l10n_key";
|
||||
|
||||
public static TText Ins { get; } = new TText(false);
|
||||
private static TText Ins { get; } = new TText(false, null);
|
||||
|
||||
public static TText NullableIns { get; } = new TText(true);
|
||||
private static TText NullableIns { get; } = new TText(true, null);
|
||||
|
||||
public TText(bool isNullable) : base(isNullable)
|
||||
public static TText Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TText(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TText(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ namespace Luban.Job.Common.Types
|
|||
{
|
||||
public bool IsNullable { get; }
|
||||
|
||||
protected TType(bool isNullable)
|
||||
public Dictionary<string, string> Tags { get; }
|
||||
|
||||
protected TType(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
IsNullable = isNullable;
|
||||
Tags = tags;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> Tags { get; set; }
|
||||
|
||||
public bool HasTag(string attrName)
|
||||
{
|
||||
return Tags != null && Tags.ContainsKey(attrName);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,28 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TVector2 : TType
|
||||
{
|
||||
public static TVector2 Ins { get; } = new TVector2(false);
|
||||
private static TVector2 Ins { get; } = new TVector2(false, null);
|
||||
|
||||
public static TVector2 NullableIns { get; } = new TVector2(true);
|
||||
private static TVector2 NullableIns { get; } = new TVector2(true, null);
|
||||
|
||||
public TVector2(bool isNullable) : base(isNullable)
|
||||
public static TVector2 Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TVector2(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TVector2(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,28 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TVector3 : TType
|
||||
{
|
||||
public static TVector3 Ins { get; } = new TVector3(false);
|
||||
private static TVector3 Ins { get; } = new TVector3(false, null);
|
||||
|
||||
public static TVector3 NullableIns { get; } = new TVector3(true);
|
||||
private static TVector3 NullableIns { get; } = new TVector3(true, null);
|
||||
|
||||
public TVector3(bool isNullable) : base(isNullable)
|
||||
public static TVector3 Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TVector3(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TVector3(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +36,7 @@ namespace Luban.Job.Common.Types
|
|||
visitor.Accept(this, x);
|
||||
}
|
||||
|
||||
public override void Apply<T1, T2>(ITypeActionVisitor<T1, T2> visitor, T1 x, T2 y)
|
||||
public override void Apply<T1, T3>(ITypeActionVisitor<T1, T3> visitor, T1 x, T3 y)
|
||||
{
|
||||
visitor.Accept(this, x, y);
|
||||
}
|
||||
|
|
@ -38,7 +51,7 @@ namespace Luban.Job.Common.Types
|
|||
return visitor.Accept(this, x);
|
||||
}
|
||||
|
||||
public override TR Apply<T1, T2, TR>(ITypeFuncVisitor<T1, T2, TR> visitor, T1 x, T2 y)
|
||||
public override TR Apply<T1, T3, TR>(ITypeFuncVisitor<T1, T3, TR> visitor, T1 x, T3 y)
|
||||
{
|
||||
return visitor.Accept(this, x, y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,28 @@
|
|||
using Luban.Job.Common.TypeVisitors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Luban.Job.Common.Types
|
||||
{
|
||||
public class TVector4 : TType
|
||||
{
|
||||
public static TVector4 Ins { get; } = new TVector4(false);
|
||||
private static TVector4 Ins { get; } = new TVector4(false, null);
|
||||
|
||||
public static TVector4 NullableIns { get; } = new TVector4(true);
|
||||
private static TVector4 NullableIns { get; } = new TVector4(true, null);
|
||||
|
||||
public TVector4(bool isNullable) : base(isNullable)
|
||||
public static TVector4 Create(bool isNullable, Dictionary<string, string> tags)
|
||||
{
|
||||
if (tags == null)
|
||||
{
|
||||
return isNullable ? NullableIns : Ins;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TVector4(isNullable, tags);
|
||||
}
|
||||
}
|
||||
|
||||
private TVector4(bool isNullable, Dictionary<string, string> tags) : base(isNullable, tags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue