public CldrData Build(string directory, PatternCollection patterns) { var cldrTreeBuilder = new CldrTreeBuilder(); var done = 0; foreach (var path in this.fileFinder.FindFiles(directory)) { var json = File.ReadAllText(path); var token = JObject.Parse(json); var wasMatched = false; foreach (var parser in this.jsonParsers) { if (!parser.IsValid(token)) { continue; } var metadata = parser.ExtractMetadata(token); parser.RemoveMetadata(token); this.versionConsistencyAssurer.AssureVersionIsConsistent(metadata?.CldrVersion, path); token.Subset(patterns); var toAdd = parser.PrepareForMerging(metadata?.CldrLocale, token); cldrTreeBuilder.Add(toAdd); wasMatched = true; } if (!wasMatched) { // react depending on the options (-ignore, -warning, -error) } done++; if (done % 100 == 0) { Console.WriteLine($"{done} files processed"); } } if (done % 100 != 0) { Console.WriteLine($"{done} files processed"); } return(new CldrData { Tree = cldrTreeBuilder.Tree }); }
public CldrData Build(string directory, PatternCollection patterns) { var cldrTreeBuilder = new CldrTreeBuilder(); var done = 0; foreach (var path in this.fileFinder.FindFiles(directory)) { var json = File.ReadAllText(path); var token = JObject.Parse(json); var wasMatched = false; foreach (var parser in this.jsonParsers) { if (!parser.IsValid(token)) continue; var metadata = parser.ExtractMetadata(token); parser.RemoveMetadata(token); this.versionConsistencyAssurer.AssureVersionIsConsistent(metadata?.CldrVersion, path); token.Subset(patterns); var toAdd = parser.PrepareForMerging(metadata?.CldrLocale, token); cldrTreeBuilder.Add(toAdd); wasMatched = true; } if (!wasMatched) { // react depending on the options (-ignore, -warning, -error) } done++; if (done % 100 == 0) Console.WriteLine($"{done} files processed"); } if (done % 100 != 0) Console.WriteLine($"{done} files processed"); return new CldrData { Tree = cldrTreeBuilder.Tree }; }