From ddf6e9d13c1b236da40460e9c54f4968c827808c Mon Sep 17 00:00:00 2001 From: "DUDULUU-R7\\duduluu" Date: Fri, 1 Dec 2017 00:33:21 +0800 Subject: [PATCH] Fix def type name case sensitivity preprocess module --- RimTrans.Builder/DefinitionData.cs | 26 +++++++------------------- RimTrans.Builder/Xml/DefTypeNameOf.cs | 15 ++++++++------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/RimTrans.Builder/DefinitionData.cs b/RimTrans.Builder/DefinitionData.cs index 86dbdb0..2fce42a 100644 --- a/RimTrans.Builder/DefinitionData.cs +++ b/RimTrans.Builder/DefinitionData.cs @@ -56,8 +56,6 @@ public static DefinitionData Load(string path, DefinitionData definitionDataCore if (definitionData._data.Count == 0) return definitionData; - definitionData.Preprocess(); - definitionData.Inherit(definitionDataCore); definitionData.MarkIndex(); @@ -102,6 +100,13 @@ private void Load(string path) { countInvalidFiles++; } if (doc != null) { + foreach (XElement def in doc.Root.Elements()) { + foreach (string defTypeName in DefTypeNameOf.AllNames) { + if (string.Compare(def.Name.ToString(), defTypeName, true) == 0 && def.Name.ToString() != defTypeName) { + def.Name = defTypeName; + } + } + } this._data.Add(filePath.Substring(splitIndex), doc); foreach (XElement abstr in from ele in doc.Root.Elements() where ele.Attribute("Name") != null @@ -145,23 +150,6 @@ where ele.Attribute("Name") != null #endregion - #region Preprocess - - private void Preprocess() { - var allDefTypeNames = DefTypeNameOf.AllNames.ToList(); - foreach (XDocument doc in this.Data.Values) { - foreach (XElement def in doc.Root.Elements()) { - foreach (string defTypeName in allDefTypeNames) { - if (string.Compare(def.Name.ToString(), defTypeName, true) == 0 && def.Name.ToString() != defTypeName) { - def.Name = defTypeName; - } - } - } - } - } - - #endregion - #region Inherit /// diff --git a/RimTrans.Builder/Xml/DefTypeNameOf.cs b/RimTrans.Builder/Xml/DefTypeNameOf.cs index d666ba5..c133ce9 100644 --- a/RimTrans.Builder/Xml/DefTypeNameOf.cs +++ b/RimTrans.Builder/Xml/DefTypeNameOf.cs @@ -6,15 +6,16 @@ namespace RimTrans.Builder.Xml { public static class DefTypeNameOf { - public static IEnumerable AllNames { - get { - Type typeDef = typeof(Def); - yield return typeDef.Name; - foreach (Type subclass in typeDef.AllSubclasses()) { - yield return subclass.Name; - } + private static IEnumerable getAllNames() { + Type typeDef = typeof(Def); + yield return typeDef.Name; + foreach (Type subclass in typeDef.AllSubclasses()) { + yield return subclass.Name; } } + private static readonly List allNames = getAllNames().ToList(); + + public static IEnumerable AllNames => allNames; //public static readonly string Unknown = "Unknown"; public static readonly string Def = "Def";