public async Task Parse() { var extendedContentChapters = new List <ChapterRules>(); foreach (var ecFile in _expandedContentFileNames) { var expandedContentProcessor = new ExpandedContentProcessor(); var extendedContent = await expandedContentProcessor.Process(new List <string> { ecFile }, _localization); if (extendedContent.SingleOrDefault() != null) { extendedContentChapters.Add(extendedContent.Single()); } } await _blobContainerClient.CreateIfNotExistsAsync(); foreach (var ec in extendedContentChapters) { var json = JsonConvert.SerializeObject(ec); var blobClient = _blobContainerClient.GetBlobClient($"{ec.ChapterName}.json"); var content = Encoding.UTF8.GetBytes(json); using (var ms = new MemoryStream(content)) { await blobClient.UploadAsync(ms, true); } var searchTerm = _globalSearchTermRepository.CreateSearchTerm(ec.ChapterName, GlobalSearchTermType.ExpandedContent, ContentType.ExpandedContent, $"/rules/expandedContent/{ec.ChapterName}"); _globalSearchTermRepository.SearchTerms.Add(searchTerm); } }
public ExpandedContentManager(CloudStorageAccount cloudStorageAccount, ILocalization localization, GlobalSearchTermRepository globalSearchTermRepository) { _localization = localization; _globalSearchTermRepository = globalSearchTermRepository; _expandedContentProcessor = new ExpandedContentProcessor(); var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); _cloudBlobContainer = cloudBlobClient.GetContainerReference($"expanded-content-{_localization.Language}"); }