public async Task Parse() { try { var expandedContentBackgroundProcessor = new ExpandedContentBackgroundProcessor(_localization); var backgrounds = await expandedContentBackgroundProcessor.Process(_ecBackgroundsFileName, _localization); foreach (var background in backgrounds) { background.ContentSourceEnum = ContentSource.EC; var backgroundSearchTerm = _globalSearchTermRepository.CreateSearchTerm(background.Name, GlobalSearchTermType.Background, ContentType.ExpandedContent, $"/characters/backgrounds/{background.Name}"); _globalSearchTermRepository.SearchTerms.Add(backgroundSearchTerm); } await _tableStorage.AddBatchAsync <Background>($"backgrounds{_localization.Language}", backgrounds, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC backgrounds."); } }
public override Task <List <Background> > FindBlocks(List <string> lines) { var backgrounds = new List <Background>(); var backgroundsStart = lines.FindIndex(f => f.Equals(Localization.StartingBackground, StringComparison.InvariantCultureIgnoreCase)); for (var i = backgroundsStart; i < lines.Count; i++) { if (!lines[i].StartsWith("## ") && !lines[i].StartsWith("## ") || lines[i].Contains(Localization.Changelog)) { continue; } var backgroundEndIndex = lines.FindIndex(i + 1, f => f.StartsWith("## ")); var backgroundLines = lines.Skip(i).ToList(); if (backgroundEndIndex != -1) { backgroundLines = lines.Skip(i).Take(backgroundEndIndex - i).CleanListOfStrings().ToList(); } var expandedContentBackgroundProcessor = new ExpandedContentBackgroundProcessor(Localization); backgrounds.Add(expandedContentBackgroundProcessor.ParseBackground(backgroundLines, ContentType.Core)); } return(Task.FromResult(backgrounds)); }