Skip to content

Commit 0391e7e

Browse files
committed
Revert "Test fix dependency injection installer issue"
This reverts commit 12dd32c.
1 parent 12dd32c commit 0391e7e

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,37 @@ 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 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.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+
}
3464

3565
[STAThread]
3666
public static void Main()
@@ -49,33 +79,6 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
4979
{
5080
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
5181
{
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-
7982
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
8083

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

0 commit comments

Comments
 (0)