From 93a802ec231bc0c54f379dec605a11b571ed0a26 Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Fri, 26 Apr 2024 21:19:20 +0300 Subject: [PATCH] Use IAsyncEnumerable --- .../PortableObjectStringLocalizer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs b/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs index b046ca127d5..db7616e9ada 100644 --- a/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs +++ b/src/OrchardCore/OrchardCore.Localization.Core/PortableObject/PortableObjectStringLocalizer.cs @@ -71,9 +71,11 @@ public virtual IEnumerable 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(); } /// @@ -120,7 +122,7 @@ private async IAsyncEnumerable GetAllStringsAsync(CultureInfo c } } - private async Task> GetAllStringsFromCultureHierarchyAsync(CultureInfo culture) + private async IAsyncEnumerable GetAllStringsFromCultureHierarchyAsync(CultureInfo culture) { var currentCulture = culture; var allLocalizedStrings = new List(); @@ -135,15 +137,13 @@ private async Task> 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.")]