Piotr Czajkowski 1 год назад
Родитель
Сommit
7774e7088f
1 измененных файлов с 8 добавлено и 5 удалено
  1. 8 5
      analyzeJSON/AnalyzeJSON.cs

+ 8 - 5
analyzeJSON/AnalyzeJSON.cs

@@ -1,5 +1,6 @@
-using System;
+using System;
 using System.IO;
 using System.IO;
+using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using Newtonsoft.Json;
 using Newtonsoft.Json;
@@ -37,13 +38,15 @@ namespace analyzeJSON
             return Regex.Replace(name, @"\[\d+?\]$", "");
             return Regex.Replace(name, @"\[\d+?\]$", "");
         }
         }
 
 
-        private void Traverse(IJEnumerable<JToken> tokens, Action<JToken> action)
+        private void TraverseWithActions(IJEnumerable<JToken> tokens, List<Action<JToken>> actions)
         {
         {
             foreach (var token in tokens)
             foreach (var token in tokens)
             {
             {
+							foreach (var action in actions)
                 action.Invoke(token);
                 action.Invoke(token);
-                if (token.HasValues)
-                    Traverse(token.Children(), action);
+              
+							if (token.HasValues)
+          			TraverseWithActions(token.Children(), actions);
             }
             }
         }
         }
 
 
@@ -55,7 +58,7 @@ namespace analyzeJSON
             if (action == null)
             if (action == null)
                 return new(false, "Action can't be null!");
                 return new(false, "Action can't be null!");
 
 
-            Traverse(json.Children(), action);
+            TraverseWithActions(json.Children(), new List<Action<JToken>>{action});
             return new(true, string.Empty);
             return new(true, string.Empty);
         }
         }
     }
     }