elsa-core/src/modules/Elsa.Http/Abstractions/DownloadableContentHandlerBase.cs
Sipke Schoorstra 225a99f39d
Bulk Import + Export of Workflow Definitions and Instances (#4643)
* Implement bulk export of workflow definitions

* Update Import endpoint with support for file uploads

* Update Import endpoint to return imported workflow count

* Implement workflow instance (bulk) export

* Implement workflow state, bookmark, workflow + activity execution export

* Remove globally imported usings
2023-11-22 14:31:48 +01:00

47 lines
1.6 KiB
C#

using Elsa.Http.Contexts;
using Elsa.Http.Contracts;
using Elsa.Http.Models;
namespace Elsa.Http.Abstractions;
/// <summary>
/// Provides a base class for <see cref="IDownloadableContentHandler"/> implementations.
/// </summary>
public abstract class DownloadableContentHandlerBase : IDownloadableContentHandler
{
/// <inheritdoc />
public virtual float Priority => 0;
/// <inheritdoc />
public abstract bool GetSupportsContent(object content);
/// <summary>
/// Returns a list of downloadables from the specified content.
/// </summary>
protected virtual IEnumerable<Func<ValueTask<Downloadable>>> GetDownloadablesAsync(DownloadableContext context)
{
return new[] { GetDownloadableAsync(context) };
}
/// <summary>
/// Returns a downloadable from the specified content.
/// </summary>
protected virtual Func<ValueTask<Downloadable>> GetDownloadableAsync(DownloadableContext context)
{
return () => ValueTask.FromResult(GetDownloadable(context));
}
/// <summary>
/// Returns a downloadable from the specified content.
/// </summary>
/// <exception cref="NotImplementedException">This method is not implemented. The derived class must implement at least one of the GetDownloadable methods.</exception>
protected virtual Downloadable GetDownloadable(DownloadableContext context)
{
throw new NotImplementedException();
}
IEnumerable<Func<ValueTask<Downloadable>>> IDownloadableContentHandler.GetDownloadablesAsync(DownloadableContext context)
{
return GetDownloadablesAsync(context);
}
}