/// <summary> /// Gets a <see cref="IEnumerable{CultureInfo}"/> containing <see cref="CultureInfo"/> instances from provided <code>requiredTranslations</code> /// which translations are not found in the provided <see cref="MarketDescriptionCacheItem"/> /// </summary> /// <param name="item">The <see cref="MarketDescriptionCacheItem"/> instance, or a null reference</param> /// <param name="requiredTranslations">The <see cref="IEnumerable{CultureInfo}"/> specifying the required languages</param> /// <returns>A <see cref="IEnumerable{CultureInfo}"/> containing missing translations or a null reference if none of the translations are missing</returns> private IEnumerable <CultureInfo> GetMissingTranslations(MarketDescriptionCacheItem item, IEnumerable <CultureInfo> requiredTranslations) { var requiredTranslationsList = requiredTranslations?.ToList(); Guard.Argument(requiredTranslationsList, nameof(requiredTranslationsList)).NotNull().NotEmpty(); if (item == null) { //return requiredTranslations; //we get only those which was not yet fetched if (requiredTranslationsList != null) { return(requiredTranslationsList.Where(c => !_fetchedLanguages.Contains(c))); } } if (requiredTranslationsList != null) { var missingCultures = requiredTranslationsList.Where(c => !item.HasTranslationsFor(c)).ToList(); return(missingCultures.Any() ? missingCultures : null); } return(null); }
/// <summary> /// Gets a <see cref="IEnumerable{CultureInfo}"/> containing <see cref="CultureInfo"/> instances from provided <code>requiredTranslations</code> /// which translations are not found in the provided <see cref="MarketDescriptionCacheItem"/> /// </summary> /// <param name="item">The <see cref="MarketDescriptionCacheItem"/> instance, or a null reference</param> /// <param name="requiredTranslations">The <see cref="IEnumerable{CultureInfo}"/> specifying the required languages</param> /// <returns>A <see cref="IEnumerable{CultureInfo}"/> containing missing translations or a null reference if none of the translations are missing</returns> private IEnumerable <CultureInfo> GetMissingTranslations(MarketDescriptionCacheItem item, IEnumerable <CultureInfo> requiredTranslations) { Guard.Argument(requiredTranslations, nameof(requiredTranslations)).NotNull(); if (!requiredTranslations.Any()) { throw new ArgumentOutOfRangeException(nameof(requiredTranslations)); } if (item == null) { //return requiredTranslations; //we get only those which was not yet fetched return(requiredTranslations.Where(c => !_fetchedLanguages.Contains(c))); } var missingCultures = requiredTranslations.Where(c => !item.HasTranslationsFor(c)).ToList(); return(missingCultures.Any() ? missingCultures : null); }