mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 22:35:23 +08:00
ExportAsync use TModel
This commit is contained in:
parent
405985ec5b
commit
951302fe61
@ -58,24 +58,21 @@ namespace osu.Game.Database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Export the model to default folder.
|
/// Export the model to default folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The model should export.</param>
|
/// <param name="model">The model should export.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
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<string> 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);
|
await ExportToStreamAsync(model, stream);
|
||||||
|
|
||||||
string itemFilename = item.GetDisplayString().GetValidFilename();
|
|
||||||
IEnumerable<string> 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user