Parcourir la source

保证生成代码嵌套数据不冲突

lichunlei il y a 3 mois
Parent
commit
fd3b887868
1 fichiers modifiés avec 10 ajouts et 26 suppressions
  1. 10 26
      Util/Maker.cs

+ 10 - 26
Util/Maker.cs

@@ -103,25 +103,17 @@ namespace Util
                                 {
                                     Dictionary<string, string> replaceDict = new Dictionary<string, string>();
                                     int index = 0;
-                                    MatchCollection subLoops = Regex.Matches(itemString, "<<ym-loop:.*?>>[\\s\\S]*?<</ym-loop:.*?>>");
+                                    MatchCollection subLoops = Regex.Matches(itemString, "<<.*?>>");
                                     foreach (Match subLoop in subLoops)
                                     {
                                         index += 1;
-                                        itemString = Regex.Replace(itemString, subLoop.Value, "${loop" + index + "}$");
-                                        replaceDict.Add("loop" + index, subLoop.Value);
-                                    }
-                                    index = 0;
-                                    MatchCollection subItems = Regex.Matches(itemString, "<<ym-item:.*?>>[\\s\\S]*?<</ym-item:.*?>>");
-                                    foreach (Match subItem in subItems)
-                                    {
-                                        index += 1;
-                                        itemString = Regex.Replace(itemString, subItem.Value, "${item" + index + "}$");
-                                        replaceDict.Add("item" + index, subItem.Value);
+                                        itemString = itemString.Replace(subLoop.Value, "${tag" + index + "}$");
+                                        replaceDict.Add("tag" + index, subLoop.Value);
                                     }
                                     itemString = itemString.Replace("<<" + itemKey + ">>", itemObj.ToString());
-                                    foreach (var replace in replaceDict)
+                                    foreach (var replaceKey in replaceDict.Keys)
                                     {
-                                        itemString = itemString.Replace("${" + replace.Key + "}$", replace.Value);
+                                        itemString = itemString.Replace("${" + replaceKey + "}$", replaceDict[replaceKey]);
                                     }
                                 }
                             }
@@ -188,25 +180,17 @@ namespace Util
                             {
                                 Dictionary<string, string> replaceDict = new Dictionary<string, string>();
                                 int index = 0;
-                                MatchCollection subLoops = Regex.Matches(itemString, "<<ym-loop:.*?>>[\\s\\S]*?<</ym-loop:.*?>>");
+                                MatchCollection subLoops = Regex.Matches(itemString, "<<.*?>>");
                                 foreach (Match subLoop in subLoops)
                                 {
                                     index += 1;
-                                    itemString = Regex.Replace(itemString, subLoop.Value, "${loop" + index + "}$");
-                                    replaceDict.Add("loop" + index, subLoop.Value);
-                                }
-                                index = 0;
-                                MatchCollection subItems = Regex.Matches(itemString, "<<ym-item:.*?>>[\\s\\S]*?<</ym-item:.*?>>");
-                                foreach (Match subItem in subItems)
-                                {
-                                    index += 1;
-                                    itemString = Regex.Replace(itemString, subItem.Value, "${item" + index + "}$");
-                                    replaceDict.Add("item" + index, subItem.Value);
+                                    itemString = Regex.Replace(itemString, subLoop.Value, "${tag" + index + "}$");
+                                    replaceDict.Add("tag" + index, subLoop.Value);
                                 }
                                 itemString = itemString.Replace("<<" + itemKey + ">>", itemObj.ToString());
-                                foreach (var replace in replaceDict)
+                                foreach (var replaceKey in replaceDict.Keys)
                                 {
-                                    itemString = itemString.Replace("${" + replace.Key + "}$", replace.Value);
+                                    itemString = itemString.Replace("${" + replaceKey + "}$", replaceDict[replaceKey]);
                                 }
                             }
                         }