public IEnumerable <IGameRecord> Traverse(ISeed relativeRoot, ISeedRootContext context) { string platformId = context.GetAllOfType("platform").FirstOrDefault()?.Content.Value; if (!this.StoneProvider.Platforms.Keys.Contains(platformId)) { yield break; } var platform = this.StoneProvider.Platforms[platformId]; var fileRecords = this.FileTraverser.Traverse(relativeRoot, context); foreach (var resultSeed in context.GetAllOfType("result")) { var children = context.GetChildren(resultSeed); var metadataSeeds = context.GetDescendants(resultSeed) .DistinctBy(p => p.Content.Type).Select(p => p.Content); var gameRecord = new GameRecord(platform, resultSeed.Content.Value); foreach (var content in metadataSeeds) { gameRecord.Metadata[$"game_{content.Type}"] = content.Value; } foreach (var file in fileRecords.Concat(this.FileTraverser.Traverse(resultSeed, context))) { gameRecord.Files.Add(file); } yield return(gameRecord); } }
public override async IAsyncEnumerable <IRecordMetadata> Traverse(IGame game, ISeed relativeRoot, ISeedRootContext context) { foreach (var result in context.GetAllOfType("result").SelectMany(s => context.GetChildren(s).Distinct())) { if (game.Record.Metadata.ContainsKey($"game_{result.Content.Type}")) { continue; } game.Record.Metadata.Add($"game_{result.Content.Type}", result.Content.Value); yield return((game.Record.Metadata as IDictionary <string, IRecordMetadata>)[$"game_{result.Content.Type}"]); } }