diff --git a/src/Nager.Country.Translation/CountryProviderExtension.cs b/src/Nager.Country.Translation/CountryProviderExtension.cs index 44798fb..2fdb754 100644 --- a/src/Nager.Country.Translation/CountryProviderExtension.cs +++ b/src/Nager.Country.Translation/CountryProviderExtension.cs @@ -3,8 +3,13 @@ namespace Nager.Country.Translation { + /// + /// CountryProvider Extension + /// public static class CountryProviderExtension { + private static readonly Lazy TranslationProvider = new Lazy(); + /// public static ICountryInfo GetCountryByNameConsiderTranslation( this ICountryProvider countryProvider, @@ -24,9 +29,8 @@ public static ICountryInfo GetCountryByNameConsiderTranslation( return country; } - var translationProvider = new TranslationProvider(); - var countryTranslation = translationProvider.GetCountryTranslation(country.Alpha2Code); - if (countryTranslation.Translations.Any(translation => translation.Name.Equals(countryName, StringComparison.OrdinalIgnoreCase))) + var countryTanslation = TranslationProvider.Value.GetCountryTranslation(country.Alpha2Code); + if (countryTanslation.Translations.Any(translation => translation.Name.Equals(countryName, StringComparison.OrdinalIgnoreCase))) { return country; }