@@ -226,34 +226,36 @@ private static JsonLocalizationOptions GetJsonLocalizationOption()
226226 return null ;
227227 }
228228
229+ IEnumerable < LocalizedString > ? localizedItems = null ;
229230 cultureName ??= CultureInfo . CurrentUICulture . Name ;
230231 var key = $ "{ nameof ( GetJsonStringByTypeName ) } -{ assembly . GetUniqueName ( ) } -{ cultureName } ";
231- var typeKey = $ "{ key } -{ typeName } ";
232232 if ( forceLoad )
233233 {
234234 Instance . Cache . Remove ( key ) ;
235- Instance . Cache . Remove ( typeKey ) ;
236235 }
237- return Instance . GetOrCreate ( typeKey , _ =>
236+
237+ lock ( assembly )
238238 {
239- var sections = Instance . GetOrCreate ( key , _ => option . GetJsonStringFromAssembly ( assembly , cultureName ) ) ;
240- var items = sections . FirstOrDefault ( kv => typeName . Equals ( kv . Key , StringComparison . OrdinalIgnoreCase ) ) ?
241- . GetChildren ( )
242- . Select ( kv =>
239+ localizedItems = Instance . GetOrCreate ( key , _ =>
240+ {
241+ var sections = option . GetJsonStringFromAssembly ( assembly , cultureName ) ;
242+ var items = sections . SelectMany ( section => section . GetChildren ( ) . Select ( kv =>
243243 {
244244 var value = kv . Value ;
245245 if ( value == null && option . UseKeyWhenValueIsNull == true )
246246 {
247247 value = kv . Key ;
248248 }
249- return new LocalizedString ( kv . Key , value ?? "" , false , typeName ) ;
250- } ) ;
249+ return new LocalizedString ( kv . Key , value ?? "" , false , section . Key ) ;
250+ } ) ) ;
251251#if NET8_0_OR_GREATER
252- return items ? . ToFrozenSet ( ) ;
252+ return items . ToFrozenSet ( ) ;
253253#else
254- return items ? . ToHashSet ( ) ;
254+ return items . ToHashSet ( ) ;
255255#endif
256- } ) ;
256+ } ) ;
257+ }
258+ return localizedItems . Where ( item => item . SearchedLocation ! . Equals ( typeName , StringComparison . OrdinalIgnoreCase ) ) ;
257259 }
258260
259261 /// <summary>
0 commit comments