mirror of https://github.com/ppy/osu
More xmldoc across new methods and classes
This commit is contained in:
parent
106d558147
commit
704e7e843f
|
@ -7,15 +7,24 @@
|
|||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information related to an active external edit operation.
|
||||
/// </summary>
|
||||
public class ExternalEditOperation<TModel> where TModel : class, IHasGuidPrimaryKey
|
||||
{
|
||||
/// <summary>
|
||||
/// The temporary path at which the model has been exported to for editing.
|
||||
/// </summary>
|
||||
public readonly string MountedPath;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the model is still mounted at <see cref="MountedPath"/>.
|
||||
/// </summary>
|
||||
public bool IsMounted { get; private set; }
|
||||
|
||||
private readonly IModelImporter<TModel> importer;
|
||||
private readonly TModel original;
|
||||
|
||||
private bool isMounted;
|
||||
|
||||
public ExternalEditOperation(IModelImporter<TModel> importer, TModel original, string path)
|
||||
{
|
||||
this.importer = importer;
|
||||
|
@ -23,14 +32,24 @@ public ExternalEditOperation(IModelImporter<TModel> importer, TModel original, s
|
|||
|
||||
MountedPath = path;
|
||||
|
||||
isMounted = true;
|
||||
IsMounted = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finish the external edit operation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This will trigger an asynchronous reimport of the model.
|
||||
/// Subsequent calls will be a no-op.
|
||||
/// </remarks>
|
||||
/// <returns>A task which will eventuate in the newly imported model with changes applied.</returns>
|
||||
public async Task<Live<TModel>?> Finish()
|
||||
{
|
||||
if (!Directory.Exists(MountedPath) || !isMounted)
|
||||
if (!Directory.Exists(MountedPath) || !IsMounted)
|
||||
return null;
|
||||
|
||||
IsMounted = false;
|
||||
|
||||
Live<TModel>? imported = await importer.ImportAsUpdate(new ProgressNotification(), new ImportTask(MountedPath), original)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
|
@ -40,8 +59,6 @@ public ExternalEditOperation(IModelImporter<TModel> importer, TModel original, s
|
|||
}
|
||||
catch { }
|
||||
|
||||
isMounted = false;
|
||||
|
||||
return imported;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@ public interface IModelImporter<TModel> : IPostNotifications, ICanAcceptFiles
|
|||
/// <summary>
|
||||
/// Mount all files for a <see cref="TModel"/> to a temporary directory to allow for external editing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When editing is completed, call <see cref="ExternalEditOperation{TModel}.Finish"/> to begin the import-and-update process.
|
||||
/// </remarks>
|
||||
/// <param name="model">The <see cref="TModel"/> to mount.</param>
|
||||
public Task<ExternalEditOperation<TModel>> BeginExternalEditing(TModel model);
|
||||
|
||||
|
|
Loading…
Reference in New Issue