From 6bcc8e74ceae8c5b221dbb9854c666894b39b974 Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 2 Dec 2021 18:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dunity=E9=A1=B9=E7=9B=AE=E4=B8=AD=E5=BD=BB=E5=BA=95?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=9F=90=E4=B8=AA=E6=A8=A1=E5=9D=97=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E9=87=8D=E6=96=B0=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E4=BC=9A=E5=B0=9D=E8=AF=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=AF=A5=E6=A8=A1=E5=9D=97=E7=9B=AE=E5=BD=95=EF=BC=8C?= =?UTF-8?q?=E7=94=B1=E4=BA=8E=E4=BF=9D=E7=95=99=E4=BA=86meta=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AF=BC=E8=87=B4=E7=9B=AE=E5=BD=95=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban.Client/Source/Utils/FileCleaner.cs | 2 +- src/Luban.Common/Source/Utils/FileUtil.cs | 19 +++++++++++++++++++ .../Source/Validators/RefValidator.cs | 2 +- .../Source/Defs/CommonDefLoader.cs | 6 +++--- .../Source/Defs/DefTypeBase.cs | 3 ++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Luban.Client/Source/Utils/FileCleaner.cs b/src/Luban.Client/Source/Utils/FileCleaner.cs index 4f5ce5f..10e5640 100644 --- a/src/Luban.Client/Source/Utils/FileCleaner.cs +++ b/src/Luban.Client/Source/Utils/FileCleaner.cs @@ -90,7 +90,7 @@ namespace Luban.Client.Common.Utils else { s_logger.Info("[remove] dir: {dir}", subDir); - Directory.Delete(subDir); + FileUtil.DeleteDirectoryRecursive(subDir); } } } diff --git a/src/Luban.Common/Source/Utils/FileUtil.cs b/src/Luban.Common/Source/Utils/FileUtil.cs index 3f2cd78..f3290cc 100644 --- a/src/Luban.Common/Source/Utils/FileUtil.cs +++ b/src/Luban.Common/Source/Utils/FileUtil.cs @@ -219,5 +219,24 @@ namespace Luban.Common.Utils } return bytes; } + + public static void DeleteDirectoryRecursive(string rootDir) + { + string[] files = Directory.GetFiles(rootDir); + string[] dirs = Directory.GetDirectories(rootDir); + + foreach (string file in files) + { + File.SetAttributes(file, FileAttributes.Normal); + File.Delete(file); + } + + foreach (string dir in dirs) + { + DeleteDirectoryRecursive(dir); + } + + Directory.Delete(rootDir, false); + } } } diff --git a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs index 919066e..952c799 100644 --- a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs +++ b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs @@ -27,7 +27,7 @@ namespace Luban.Job.Cfg.Validators public RefValidator(TType type, string tablesStr) { Type = type; - this.Tables = new List(DefUtil.TrimBracePairs(tablesStr).Split(',')); + this.Tables = DefUtil.TrimBracePairs(tablesStr).Split(',').Select(s => s.Trim()).ToList(); } public void Validate(ValidatorContext ctx, TType type, DType key) diff --git a/src/Luban.Job.Common/Source/Defs/CommonDefLoader.cs b/src/Luban.Job.Common/Source/Defs/CommonDefLoader.cs index 847e1ed..c7ba11f 100644 --- a/src/Luban.Job.Common/Source/Defs/CommonDefLoader.cs +++ b/src/Luban.Job.Common/Source/Defs/CommonDefLoader.cs @@ -164,7 +164,7 @@ namespace Luban.Job.Common.Defs private void AddModule(string defineFile, XElement me) { - var name = XmlUtil.GetOptionalAttribute(me, "name"); + var name = XmlUtil.GetOptionalAttribute(me, "name")?.Trim(); //if (string.IsNullOrEmpty(name)) //{ // throw new LoadDefException($"xml:{CurImportFile} contains module which's name is empty"); @@ -235,7 +235,7 @@ namespace Luban.Job.Common.Defs } var b = new Bean() { - Name = XmlUtil.GetRequiredAttribute(e, "name"), + Name = XmlUtil.GetRequiredAttribute(e, "name").Trim(), Namespace = CurNamespace, Parent = parent.Length > 0 ? parent : "", TypeId = XmlUtil.GetOptionIntAttribute(e, "id"), @@ -319,7 +319,7 @@ namespace Luban.Job.Common.Defs ValidAttrKeys(defineFile, e, _enumOptionalAttrs, _enumRequiredAttrs); var en = new PEnum() { - Name = XmlUtil.GetRequiredAttribute(e, "name"), + Name = XmlUtil.GetRequiredAttribute(e, "name").Trim(), Namespace = CurNamespace, Comment = XmlUtil.GetOptionalAttribute(e, "comment"), IsFlags = XmlUtil.GetOptionBoolAttribute(e, "flags"), diff --git a/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs b/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs index 84bee7b..8703be8 100644 --- a/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs +++ b/src/Luban.Job.Common/Source/Defs/DefTypeBase.cs @@ -81,7 +81,8 @@ namespace Luban.Job.Common.Defs { return null; } - return ExternalType.Mappers.Find(m => m.Lan == DefAssemblyBase.LocalAssebmly.CurrentLanguage); + + return ExternalType.Mappers.Find(m => m.Lan == this.AssemblyBase.CurrentLanguage && this.AssemblyBase.CurrentExternalSelectors.Contains(m.Selector)); } }