From 951302fe61374cb8b4cc1dedf830c6d8fe748ae6 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Sat, 10 Dec 2022 00:43:03 +0900 Subject: [PATCH] ExportAsync use TModel --- osu.Game/Database/LegacyModelExporter.cs | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/osu.Game/Database/LegacyModelExporter.cs b/osu.Game/Database/LegacyModelExporter.cs index ae092d15e8..ad61338c8b 100644 --- a/osu.Game/Database/LegacyModelExporter.cs +++ b/osu.Game/Database/LegacyModelExporter.cs @@ -58,24 +58,21 @@ namespace osu.Game.Database /// /// Export the model to default folder. /// - /// The model should export. + /// The model should export. /// - public async Task ExportAsync(RealmObject item) + public async Task ExportAsync(TModel model) { - if (item is TModel model) + notifications?.Post(notification); + + string itemFilename = model.GetDisplayString().GetValidFilename(); + IEnumerable existingExports = exportStorage.GetFiles("", $"{itemFilename}*{FileExtension}"); + string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); + + notification.CompletionClickAction += () => exportStorage.PresentFileExternally(filename); + + using (var stream = exportStorage.CreateFileSafely(filename)) { - notifications?.Post(notification); - - string itemFilename = item.GetDisplayString().GetValidFilename(); - IEnumerable existingExports = exportStorage.GetFiles("", $"{itemFilename}*{FileExtension}"); - string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}"); - - notification.CompletionClickAction += () => exportStorage.PresentFileExternally(filename); - - using (var stream = exportStorage.CreateFileSafely(filename)) - { - await ExportToStreamAsync(model, stream); - } + await ExportToStreamAsync(model, stream); } }