From 20cd8c8260dd5ac242e1a9889f1cf20c9317e8dd Mon Sep 17 00:00:00 2001 From: sabihoshi Date: Mon, 17 May 2021 23:13:49 +0800 Subject: [PATCH] Change MediaPlayer service to Singleton --- GenshinLyreMidiPlayer.WPF/Bootstrapper.cs | 18 +++++++++--------- .../GenshinLyreMidiPlayer.WPF.csproj | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GenshinLyreMidiPlayer.WPF/Bootstrapper.cs b/GenshinLyreMidiPlayer.WPF/Bootstrapper.cs index 258c6b2..f015954 100644 --- a/GenshinLyreMidiPlayer.WPF/Bootstrapper.cs +++ b/GenshinLyreMidiPlayer.WPF/Bootstrapper.cs @@ -40,11 +40,10 @@ public Bootstrapper() protected override void ConfigureIoC(IStyletIoCBuilder builder) { - var level = ConfigurationUserLevel.PerUserRoamingAndLocal; - var config = ConfigurationManager.OpenExeConfiguration(level); + var config = ConfigurationManager + .OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); var path = Path.GetDirectoryName(config.FilePath); - if (!Directory.Exists(path)) Directory.CreateDirectory(path); @@ -72,18 +71,19 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder) Task.Run(async () => { - var icon = Path.Combine(path!, "icon.png"); - var uri = new Uri("pack://application:,,,/item_windsong_lyre.png"); + const string name = "item_windsong_lyre.png"; + var location = Path.Combine(path!, name); + + var uri = new Uri($"pack://application:,,,/{name}"); var resource = Application.GetResourceStream(uri)!.Stream; - Image.FromStream(resource) - .Save(icon); + Image.FromStream(resource).Save(location); - var file = await StorageFile.GetFileFromPathAsync(icon); + var file = await StorageFile.GetFileFromPathAsync(location); controls.DisplayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromFile(file); }); return player; - }); + }).InSingletonScope(); } } } \ No newline at end of file diff --git a/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj b/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj index 1ec689f..691a5cd 100644 --- a/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj +++ b/GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj @@ -6,7 +6,7 @@ true GenshinLyreMidiPlayer.WPF.App app.manifest - 1.10.2 + 1.10.3 item_windsong_lyre.ico enable https://github.com/sabihoshi/GenshinLyreMidiPlayer