Skip to content

Commit 9e8a950

Browse files
committed
Fix build issue & Improve code quality
1 parent c8a9e5e commit 9e8a950

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

Flow.Launcher.Infrastructure/PinyinAlphabet.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using System;
2-
using System.Collections.Concurrent;
1+
using System.Collections.Concurrent;
32
using System.Text;
4-
using JetBrains.Annotations;
53
using Flow.Launcher.Infrastructure.UserSettings;
64
using ToolGood.Words.Pinyin;
75
using 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

Comments
 (0)