From f024ec6974ca47f2786847aea9734db5aa04f60d Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 20 Nov 2021 15:55:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B0=83=E6=95=B4=E3=80=91=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E7=89=B9=E6=AE=8Atag:=20no=EF=BC=8C=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E8=A1=A8=E7=A4=BA=E4=B8=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/DataVisitors/ValidatorVisitor.cs | 102 +------------- src/Luban.Job.Cfg/Source/Utils/DataUtil.cs | 6 +- src/Luban.Job.Cfg/Source/ValidatorContext.cs | 3 - .../TypeVisitors/TypeActionVisitorAdaptor.cs | 127 ++++++++++++++++++ 4 files changed, 134 insertions(+), 104 deletions(-) create mode 100644 src/Luban.Job.Common/Source/TypeVisitors/TypeActionVisitorAdaptor.cs diff --git a/src/Luban.Job.Cfg/Source/DataVisitors/ValidatorVisitor.cs b/src/Luban.Job.Cfg/Source/DataVisitors/ValidatorVisitor.cs index b20a10f..1ed2a9b 100644 --- a/src/Luban.Job.Cfg/Source/DataVisitors/ValidatorVisitor.cs +++ b/src/Luban.Job.Cfg/Source/DataVisitors/ValidatorVisitor.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; namespace Luban.Job.Cfg.DataVisitors { - public class ValidatorVisitor : ITypeActionVisitor + public class ValidatorVisitor : TypeActionVisitorAdaptor { public const string TAG_UNCHECKED = "unchecked"; @@ -97,77 +97,7 @@ namespace Luban.Job.Cfg.DataVisitors } } - public void Accept(TBool type, DType x) - { - - } - - public void Accept(TByte type, DType x) - { - - } - - public void Accept(TShort type, DType x) - { - - } - - public void Accept(TFshort type, DType x) - { - - } - - public void Accept(TInt type, DType x) - { - - } - - public void Accept(TFint type, DType x) - { - - } - - public void Accept(TLong type, DType x) - { - - } - - public void Accept(TFlong type, DType x) - { - - } - - public void Accept(TFloat type, DType x) - { - - } - - public void Accept(TDouble type, DType x) - { - - } - - public void Accept(TEnum type, DType x) - { - - } - - public void Accept(TString type, DType x) - { - - } - - public void Accept(TBytes type, DType x) - { - - } - - public void Accept(TText type, DType x) - { - - } - - public void Accept(TBean type, DType x) + public override void Accept(TBean type, DType x) { var beanData = (DBean)x; var defFields = ((DefBean)type.Bean.AssemblyBase.GetDefType(beanData.ImplType.FullName)).HierarchyFields;// beanData.ImplType.HierarchyFields; @@ -197,22 +127,22 @@ namespace Luban.Job.Cfg.DataVisitors } } - public void Accept(TArray type, DType x) + public override void Accept(TArray type, DType x) { AcceptListLike(type.ElementType, ((DArray)x).Datas); } - public void Accept(TList type, DType x) + public override void Accept(TList type, DType x) { AcceptListLike(type.ElementType, ((DList)x).Datas); } - public void Accept(TSet type, DType x) + public override void Accept(TSet type, DType x) { AcceptListLike(type.ElementType, ((DSet)x).Datas); } - public void Accept(TMap type, DType x) + public override void Accept(TMap type, DType x) { var keyType = type.KeyType; var valueType = type.ValueType; @@ -262,25 +192,5 @@ namespace Luban.Job.Cfg.DataVisitors } } } - - public void Accept(TVector2 type, DType x) - { - - } - - public void Accept(TVector3 type, DType x) - { - - } - - public void Accept(TVector4 type, DType x) - { - - } - - public void Accept(TDateTime type, DType x) - { - - } } } diff --git a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs index bcbca91..64b8ac1 100644 --- a/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs +++ b/src/Luban.Job.Cfg/Source/Utils/DataUtil.cs @@ -124,11 +124,7 @@ namespace Luban.Job.Cfg.Utils public static bool IsIgnoreTag(string tagName) { - return !string.IsNullOrEmpty(tagName) && - ( - tagName.Equals("no", System.StringComparison.OrdinalIgnoreCase) - || tagName.Equals("##", System.StringComparison.Ordinal) - ); + return tagName == "##"; } public static List ParseTags(string rawTagStr) diff --git a/src/Luban.Job.Cfg/Source/ValidatorContext.cs b/src/Luban.Job.Cfg/Source/ValidatorContext.cs index 527349b..cb1d138 100644 --- a/src/Luban.Job.Cfg/Source/ValidatorContext.cs +++ b/src/Luban.Job.Cfg/Source/ValidatorContext.cs @@ -41,8 +41,6 @@ namespace Luban.Job.Cfg public string RootDir { get; } - - private readonly List _pathQuerys = new List(1000); public void AddPathQuery(PathQuery query) @@ -53,7 +51,6 @@ namespace Luban.Job.Cfg } } - public List GetPathQueries() => _pathQuerys; public ValidatorContext(DefAssembly ass, string rootDir) diff --git a/src/Luban.Job.Common/Source/TypeVisitors/TypeActionVisitorAdaptor.cs b/src/Luban.Job.Common/Source/TypeVisitors/TypeActionVisitorAdaptor.cs new file mode 100644 index 0000000..6ae8d3f --- /dev/null +++ b/src/Luban.Job.Common/Source/TypeVisitors/TypeActionVisitorAdaptor.cs @@ -0,0 +1,127 @@ +using Luban.Job.Common.Types; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Luban.Job.Common.TypeVisitors +{ + public abstract class TypeActionVisitorAdaptor : ITypeActionVisitor + { + public virtual void Accept(TBool type, T x) + { + + } + + public virtual void Accept(TByte type, T x) + { + + } + + public virtual void Accept(TShort type, T x) + { + + } + + public virtual void Accept(TFshort type, T x) + { + + } + + public virtual void Accept(TInt type, T x) + { + + } + + public virtual void Accept(TFint type, T x) + { + + } + + public virtual void Accept(TLong type, T x) + { + + } + + public virtual void Accept(TFlong type, T x) + { + + } + + public virtual void Accept(TFloat type, T x) + { + + } + + public virtual void Accept(TDouble type, T x) + { + + } + + public virtual void Accept(TEnum type, T x) + { + + } + + public virtual void Accept(TString type, T x) + { + + } + + public virtual void Accept(TBytes type, T x) + { + + } + + public virtual void Accept(TText type, T x) + { + + } + + public virtual void Accept(TBean type, T x) + { + + } + + public virtual void Accept(TArray type, T x) + { + + } + + public virtual void Accept(TList type, T x) + { + + } + + public virtual void Accept(TSet type, T x) + { + + } + + public virtual void Accept(TMap type, T x) + { + + } + + public virtual void Accept(TVector2 type, T x) + { + + } + + public virtual void Accept(TVector3 type, T x) + { + + } + + public virtual void Accept(TVector4 type, T x) + { + + } + + public virtual void Accept(TDateTime type, T x) + { + + } + } +}