1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

change abstract implement

This commit is contained in:
cdwcgt 2022-12-15 21:39:48 +09:00
parent c9cffc8248
commit 6900d0120a
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
3 changed files with 18 additions and 7 deletions

View File

@ -6,7 +6,7 @@ using osu.Game.Beatmaps;
namespace osu.Game.Database
{
public class LegacyBeatmapExporter : LegacyModelExporter<BeatmapSetInfo>
public class LegacyBeatmapExporter : LegacyArchiveExporter<BeatmapSetInfo>
{
public LegacyBeatmapExporter(Storage storage, RealmAccess realm)
: base(storage, realm)

View File

@ -32,7 +32,7 @@ namespace osu.Game.Database
protected RealmAccess RealmAccess;
private bool canCancel = true;
protected bool CanCancel = true;
private string filename = string.Empty;
public Action<Notification>? PostNotification { get; set; }
@ -76,9 +76,9 @@ namespace osu.Game.Database
CompletionText = "Export completed"
};
notification.CompletionClickAction += () => exportStorage.PresentFileExternally(filename);
notification.CancelRequested += () => canCancel;
notification.CancelRequested += () => CanCancel;
PostNotification?.Invoke(notification);
canCancel = true;
CanCancel = true;
Guid id = model.ID;
await Task.Run(() =>
@ -115,7 +115,18 @@ namespace osu.Game.Database
/// <param name="model">The item to export.</param>
/// <param name="outputStream">The output stream to export to.</param>
/// <param name="notification">The notification will displayed to the user</param>
protected virtual void ExportToStream(TModel model, Stream outputStream, ProgressNotification notification) => exportZipArchive(model, outputStream, notification);
protected abstract void ExportToStream(TModel model, Stream outputStream, ProgressNotification notification);
}
public abstract class LegacyArchiveExporter<TModel> : LegacyModelExporter<TModel>
where TModel : RealmObject, IHasNamedFiles, IHasGuidPrimaryKey
{
protected LegacyArchiveExporter(Storage storage, RealmAccess realm)
: base(storage, realm)
{
}
protected override void ExportToStream(TModel model, Stream outputStream, ProgressNotification notification) => exportZipArchive(model, outputStream, notification);
/// <summary>
/// Exports an item to Stream as a legacy (.zip based) package.
@ -140,7 +151,7 @@ namespace osu.Game.Database
}
notification.Text = "Saving Zip Archive...";
canCancel = false;
CanCancel = false;
archive.SaveTo(outputStream);
}
}

View File

@ -6,7 +6,7 @@ using osu.Game.Skinning;
namespace osu.Game.Database
{
public class LegacySkinExporter : LegacyModelExporter<SkinInfo>
public class LegacySkinExporter : LegacyArchiveExporter<SkinInfo>
{
public LegacySkinExporter(Storage storage, RealmAccess realm)
: base(storage, realm)