From 78f243651e82155b5cb80b70e5aaa1dfc3899b8f Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Mon, 9 Dec 2019 20:47:24 +0100 Subject: [PATCH] Pass Settings instance to Alphabet again --- Wox.Infrastructure/Alphabet.cs | 21 +++++++++------------ Wox/App.xaml.cs | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Wox.Infrastructure/Alphabet.cs b/Wox.Infrastructure/Alphabet.cs index a2f64241a4..ee6b84b418 100644 --- a/Wox.Infrastructure/Alphabet.cs +++ b/Wox.Infrastructure/Alphabet.cs @@ -15,15 +15,12 @@ namespace Wox.Infrastructure private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat(); private static ConcurrentDictionary PinyinCache; private static BinaryStorage> _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) - { - InitializePinyinHelpers(); - } + _settings = settings; + InitializePinyinHelpers(); } private static void InitializePinyinHelpers() @@ -43,7 +40,7 @@ namespace Wox.Infrastructure public static void Save() { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return; } @@ -59,7 +56,7 @@ namespace Wox.Infrastructure /// public static string[] Pinyin(string word) { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return EmptyStringArray; } @@ -81,7 +78,7 @@ namespace Wox.Infrastructure /// public static string[][] PinyinComination(string characters) { - if (!_shouldUsePinyin || string.IsNullOrEmpty(characters)) + if (!_settings.ShouldUsePinyin || string.IsNullOrEmpty(characters)) { return Empty2DStringArray; } @@ -122,7 +119,7 @@ namespace Wox.Infrastructure public static bool ContainsChinese(string word) { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return false; } @@ -140,7 +137,7 @@ namespace Wox.Infrastructure private static string[] Combination(string[] array1, string[] array2) { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return EmptyStringArray; } diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index acfb88d266..8cdc4a8b85 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -53,7 +53,7 @@ namespace Wox _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; - Alphabet.Initialize(_settings.ShouldUsePinyin); + Alphabet.Initialize(_settings); StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;