1- using System ;
2- using System . Collections . Concurrent ;
1+ using System . Collections . Concurrent ;
32using System . Text ;
4- using JetBrains . Annotations ;
53using Flow . Launcher . Infrastructure . UserSettings ;
64using ToolGood . Words . Pinyin ;
75using System . Collections . Generic ;
@@ -15,11 +13,11 @@ public class PinyinAlphabet : IAlphabet
1513 private readonly ConcurrentDictionary < string , ( string translation , TranslationMapping map ) > _pinyinCache =
1614 new ( ) ;
1715
18- private Settings _settings ;
16+ private readonly Settings _settings ;
1917
20- public void Initialize ( [ NotNull ] Settings settings )
18+ public PinyinAlphabet ( )
2119 {
22- _settings = settings ?? throw new ArgumentNullException ( nameof ( settings ) ) ;
20+ _settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
2321 }
2422
2523 public bool ShouldTranslate ( string stringToTranslate )
@@ -109,16 +107,6 @@ public bool ShouldTranslate(string stringToTranslate)
109107 { "Sh" , "u" } ,
110108 { "Zh" , "v" }
111109 } ) ;
112-
113- public PinyinAlphabet ( )
114- {
115- Initialize ( Ioc . Default . GetRequiredService < Settings > ( ) ) ;
116- }
117-
118- private void Initialize ( [ NotNull ] Settings settings )
119- {
120- _settings = settings ?? throw new ArgumentNullException ( nameof ( settings ) ) ;
121- }
122110
123111 private static readonly ReadOnlyDictionary < string , string > second = new ( new Dictionary < string , string > ( )
124112 {
@@ -200,6 +188,7 @@ private static string ToDoublePin(string fullPinyin)
200188
201189 return doublePin . ToString ( ) ;
202190 }
191+
203192 #endregion
204193 }
205194}
0 commit comments