Skip to content

Commit 12dd32c

Browse files
committed
Test fix dependency injection installer issue
1 parent e299721 commit 12dd32c

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,7 @@ public partial class App : IDisposable, ISingleInstanceApp
3030
public static IPublicAPI API { get; private set; }
3131
private const string Unique = "Flow.Launcher_Unique_Application_Mutex";
3232
private static bool _disposed;
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.SetStorage(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(sp => new Updater(sp.GetRequiredService<IPublicAPI>(), Launcher.Properties.Settings.Default.GithubRepo))
49-
.AddSingleton<Portable>()
50-
.AddSingleton<SettingWindowViewModel>()
51-
.AddSingleton<IAlphabet, PinyinAlphabet>()
52-
.AddSingleton<StringMatcher>()
53-
.AddSingleton<Internationalization>()
54-
.AddSingleton<IPublicAPI, PublicAPIInstance>()
55-
.AddSingleton<MainViewModel>()
56-
.AddSingleton<Theme>()
57-
).Build();
58-
Ioc.Default.ConfigureServices(host.Services);
59-
60-
// Initialize the public API and Settings first
61-
API = Ioc.Default.GetRequiredService<IPublicAPI>();
62-
_settings.Initialize();
63-
}
33+
private Settings _settings;
6434

6535
[STAThread]
6636
public static void Main()
@@ -79,6 +49,33 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
7949
{
8050
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
8151
{
52+
// Initialize settings
53+
var storage = new FlowLauncherJsonStorage<Settings>();
54+
_settings = storage.Load();
55+
_settings.SetStorage(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(sp => new Updater(sp.GetRequiredService<IPublicAPI>(), Launcher.Properties.Settings.Default.GithubRepo))
64+
.AddSingleton<Portable>()
65+
.AddSingleton<SettingWindowViewModel>()
66+
.AddSingleton<IAlphabet, PinyinAlphabet>()
67+
.AddSingleton<StringMatcher>()
68+
.AddSingleton<Internationalization>()
69+
.AddSingleton<IPublicAPI, PublicAPIInstance>()
70+
.AddSingleton<MainViewModel>()
71+
.AddSingleton<Theme>()
72+
).Build();
73+
Ioc.Default.ConfigureServices(host.Services);
74+
75+
// Initialize the public API and Settings first
76+
API = Ioc.Default.GetRequiredService<IPublicAPI>();
77+
_settings.Initialize();
78+
8279
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
8380

8481
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");

0 commit comments

Comments
 (0)