| | | 1 | | using Elsa.Http.Contexts; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Http.Abstractions; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Provides a base class for <see cref="IDownloadableContentHandler"/> implementations. |
| | | 7 | | /// </summary> |
| | | 8 | | public abstract class DownloadableContentHandlerBase : IDownloadableContentHandler |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | 0 | 11 | | public virtual float Priority => 0; |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | | 14 | | public abstract bool GetSupportsContent(object content); |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Returns a list of downloadables from the specified content. |
| | | 18 | | /// </summary> |
| | | 19 | | protected virtual IEnumerable<Func<ValueTask<Downloadable>>> GetDownloadablesAsync(DownloadableContext context) |
| | | 20 | | { |
| | 0 | 21 | | return new[] { GetDownloadableAsync(context) }; |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Returns a downloadable from the specified content. |
| | | 26 | | /// </summary> |
| | | 27 | | protected virtual Func<ValueTask<Downloadable>> GetDownloadableAsync(DownloadableContext context) |
| | | 28 | | { |
| | 0 | 29 | | return () => ValueTask.FromResult(GetDownloadable(context)); |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Returns a downloadable from the specified content. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <exception cref="NotImplementedException">This method is not implemented. The derived class must implement at le |
| | | 36 | | protected virtual Downloadable GetDownloadable(DownloadableContext context) |
| | | 37 | | { |
| | 0 | 38 | | throw new NotImplementedException(); |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | IEnumerable<Func<ValueTask<Downloadable>>> IDownloadableContentHandler.GetDownloadablesAsync(DownloadableContext con |
| | | 42 | | { |
| | 0 | 43 | | return GetDownloadablesAsync(context); |
| | | 44 | | } |
| | | 45 | | } |