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