@@ -56,11 +56,10 @@ public void Setup()
5656 /// </returns>
5757 public string ? GetAssociatedValue < T > ( T enumValue ) where T : struct
5858 {
59- var currentItems = ( IDictionary < string , object > ) Items ;
6059 var enumItemName = enumValue . GetType ( ) . Name + "." + Enum . GetName ( typeof ( T ) , enumValue ) ;
6160
62- return currentItems . ContainsKey ( enumItemName )
63- ? currentItems [ enumItemName ] as string
61+ return Items . TryGetValue ( enumItemName , out var item )
62+ ? item as string
6463 : null ;
6564 }
6665
@@ -70,10 +69,8 @@ public void Setup()
7069 /// <param name="itemName">Name of the item.</param>
7170 public string ? GetItem ( string itemName )
7271 {
73- var currentItems = ( IDictionary < string , object > ) Items ;
74-
75- if ( currentItems . ContainsKey ( itemName ) )
76- return currentItems [ itemName ] as string ;
72+ if ( Items . TryGetValue ( itemName , out var item ) )
73+ return item as string ;
7774
7875 return null ;
7976 }
@@ -135,17 +132,17 @@ private void TryLoad()
135132
136133 private bool TryGetStringTableFromCache ( )
137134 {
138- if ( ! Cache . ContainsKey ( _languageManager . Language ) )
135+ if ( ! Cache . TryGetValue ( _languageManager . Language , out var value ) )
139136 return false ;
140137
141- Items = Cache [ _languageManager . Language ] ;
138+ Items = value ;
142139
143140 return true ;
144141 }
145142
146143 private IDictionary < string , object ? > Load ( )
147144 {
148- IDictionary < string , object ? > currentItems = new ExpandoObject ( ) ! ;
145+ IDictionary < string , object ? > currentItems = new ExpandoObject ( ) ;
149146
150147 foreach ( var file in stringTableFiles )
151148 Load ( file , defaultLanguage , _languageManager . Language , fileReader , currentItems ) ;
0 commit comments