@@ -30,7 +30,31 @@ public partial class App : IDisposable, ISingleInstanceApp
30
30
public static IPublicAPI API { get ; private set ; }
31
31
private const string Unique = "Flow.Launcher_Unique_Application_Mutex" ;
32
32
private static bool _disposed ;
33
- private Settings _settings ;
33
+ private readonly Settings _settings ;
34
+
35
+ public App ( )
36
+ {
37
+ // Initialize settings
38
+ var storage = new FlowLauncherJsonStorage < Settings > ( ) ;
39
+ _settings = storage . Load ( ) ;
40
+ _settings . Initialize ( storage ) ;
41
+ _settings . WMPInstalled = WindowsMediaPlayerHelper . IsWindowsMediaPlayerInstalled ( ) ;
42
+
43
+ // Configure the dependency injection container
44
+ var host = Host . CreateDefaultBuilder ( )
45
+ . UseContentRoot ( AppContext . BaseDirectory )
46
+ . ConfigureServices ( services => services
47
+ . AddSingleton ( _ => _settings )
48
+ . AddSingleton < Updater > ( )
49
+ . AddSingleton < Portable > ( )
50
+ . AddSingleton < SettingWindowViewModel > ( )
51
+ . AddSingleton < IAlphabet , PinyinAlphabet > ( )
52
+ . AddSingleton < StringMatcher > ( )
53
+ . AddSingleton < IPublicAPI , PublicAPIInstance > ( )
54
+ . AddSingleton < MainViewModel > ( )
55
+ ) . Build ( ) ;
56
+ Ioc . Default . ConfigureServices ( host . Services ) ;
57
+ }
34
58
35
59
[ STAThread ]
36
60
public static void Main ( )
@@ -49,27 +73,6 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
49
73
{
50
74
await Stopwatch . NormalAsync ( "|App.OnStartup|Startup cost" , async ( ) =>
51
75
{
52
- // Initialize settings
53
- var storage = new FlowLauncherJsonStorage < Settings > ( ) ;
54
- _settings = storage . Load ( ) ;
55
- _settings . Initialize ( storage ) ;
56
- _settings . WMPInstalled = WindowsMediaPlayerHelper . IsWindowsMediaPlayerInstalled ( ) ;
57
-
58
- // Configure the dependency injection container
59
- var host = Host . CreateDefaultBuilder ( )
60
- . UseContentRoot ( AppContext . BaseDirectory )
61
- . ConfigureServices ( services => services
62
- . AddSingleton ( _ => _settings )
63
- . AddSingleton < Updater > ( )
64
- . AddSingleton < Portable > ( )
65
- . AddSingleton < SettingWindowViewModel > ( )
66
- . AddSingleton < IAlphabet , PinyinAlphabet > ( )
67
- . AddSingleton < StringMatcher > ( )
68
- . AddSingleton < IPublicAPI , PublicAPIInstance > ( )
69
- . AddSingleton < MainViewModel > ( )
70
- ) . Build ( ) ;
71
- Ioc . Default . ConfigureServices ( host . Services ) ;
72
-
73
76
API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
74
77
75
78
Ioc . Default . GetRequiredService < Updater > ( ) . Initialize ( Launcher . Properties . Settings . Default . GithubRepo ) ;
0 commit comments