Pass Settings instance to Alphabet again

This commit is contained in:
SysC0mp 2019-12-09 20:47:24 +01:00
parent f4a2f67db3
commit 78f243651e
2 changed files with 10 additions and 13 deletions

View File

@ -15,16 +15,13 @@ namespace Wox.Infrastructure
private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat(); private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat();
private static ConcurrentDictionary<string, string[][]> PinyinCache; private static ConcurrentDictionary<string, string[][]> PinyinCache;
private static BinaryStorage<ConcurrentDictionary<string, string[][]>> _pinyinStorage; private static BinaryStorage<ConcurrentDictionary<string, string[][]>> _pinyinStorage;
private static bool _shouldUsePinyin = true; private static Settings _settings;
public static void Initialize(bool shouldUsePinyin = true) public static void Initialize(Settings settings)
{
_shouldUsePinyin = shouldUsePinyin;
if (_shouldUsePinyin)
{ {
_settings = settings;
InitializePinyinHelpers(); InitializePinyinHelpers();
} }
}
private static void InitializePinyinHelpers() private static void InitializePinyinHelpers()
{ {
@ -43,7 +40,7 @@ namespace Wox.Infrastructure
public static void Save() public static void Save()
{ {
if (!_shouldUsePinyin) if (!_settings.ShouldUsePinyin)
{ {
return; return;
} }
@ -59,7 +56,7 @@ namespace Wox.Infrastructure
/// </summary> /// </summary>
public static string[] Pinyin(string word) public static string[] Pinyin(string word)
{ {
if (!_shouldUsePinyin) if (!_settings.ShouldUsePinyin)
{ {
return EmptyStringArray; return EmptyStringArray;
} }
@ -81,7 +78,7 @@ namespace Wox.Infrastructure
/// </summmary> /// </summmary>
public static string[][] PinyinComination(string characters) public static string[][] PinyinComination(string characters)
{ {
if (!_shouldUsePinyin || string.IsNullOrEmpty(characters)) if (!_settings.ShouldUsePinyin || string.IsNullOrEmpty(characters))
{ {
return Empty2DStringArray; return Empty2DStringArray;
} }
@ -122,7 +119,7 @@ namespace Wox.Infrastructure
public static bool ContainsChinese(string word) public static bool ContainsChinese(string word)
{ {
if (!_shouldUsePinyin) if (!_settings.ShouldUsePinyin)
{ {
return false; return false;
} }
@ -140,7 +137,7 @@ namespace Wox.Infrastructure
private static string[] Combination(string[] array1, string[] array2) private static string[] Combination(string[] array1, string[] array2)
{ {
if (!_shouldUsePinyin) if (!_settings.ShouldUsePinyin)
{ {
return EmptyStringArray; return EmptyStringArray;
} }

View File

@ -53,7 +53,7 @@ namespace Wox
_settingsVM = new SettingWindowViewModel(); _settingsVM = new SettingWindowViewModel();
_settings = _settingsVM.Settings; _settings = _settingsVM.Settings;
Alphabet.Initialize(_settings.ShouldUsePinyin); Alphabet.Initialize(_settings);
StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;