Skip to content

Commit

Permalink
Use IAsyncEnumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco committed Apr 26, 2024
1 parent ee4a668 commit 93a802e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ public virtual IEnumerable<LocalizedString> GetAllStrings(bool includeParentCult
{
var culture = CultureInfo.CurrentUICulture;

return includeParentCultures
? GetAllStringsFromCultureHierarchyAsync(culture).GetAwaiter().GetResult()
: GetAllStringsAsync(culture).ToEnumerable();
var localizedStrings = includeParentCultures
? GetAllStringsFromCultureHierarchyAsync(culture)
: GetAllStringsAsync(culture);

return localizedStrings.ToEnumerable();
}

/// <inheritdocs />
Expand Down Expand Up @@ -120,7 +122,7 @@ private async IAsyncEnumerable<LocalizedString> GetAllStringsAsync(CultureInfo c
}
}

private async Task<List<LocalizedString>> GetAllStringsFromCultureHierarchyAsync(CultureInfo culture)
private async IAsyncEnumerable<LocalizedString> GetAllStringsFromCultureHierarchyAsync(CultureInfo culture)
{
var currentCulture = culture;
var allLocalizedStrings = new List<LocalizedString>();
Expand All @@ -135,15 +137,13 @@ private async Task<List<LocalizedString>> GetAllStringsFromCultureHierarchyAsync
{
if (!allLocalizedStrings.Any(ls => ls.Name == localizedString.Name))
{
allLocalizedStrings.Add(localizedString);
yield return localizedString;
}
}
}

currentCulture = currentCulture.Parent;
} while (currentCulture != currentCulture.Parent);

return allLocalizedStrings;
}

[Obsolete("This method is deprecated, please use GetTranslationAsync instead.")]
Expand Down

0 comments on commit 93a802e

Please sign in to comment.