| | | 1 | | using System.Reflection; |
| | | 2 | | using Elsa.Http.ContentWriters; |
| | | 3 | | using Elsa.Workflows.UIHints.Dropdown; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Http.UIHints; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Provides options for the <see cref="SendHttpRequest"/> activity's <see cref="SendHttpRequestBase.ContentType"/> prop |
| | | 9 | | /// </summary> |
| | | 10 | | public class HttpContentTypeOptionsProvider : DropDownOptionsProviderBase |
| | | 11 | | { |
| | | 12 | | private readonly IEnumerable<IHttpContentFactory> _httpContentFactories; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Creates a new instance of the <see cref="HttpContentTypeOptionsProvider"/> class. |
| | | 16 | | /// </summary> |
| | 1122 | 17 | | public HttpContentTypeOptionsProvider(IEnumerable<IHttpContentFactory> httpContentFactories) |
| | | 18 | | { |
| | 1122 | 19 | | _httpContentFactories = httpContentFactories; |
| | 1122 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | protected override ValueTask<ICollection<SelectListItem>> GetItemsAsync(PropertyInfo propertyInfo, object? context, |
| | | 24 | | { |
| | 560 | 25 | | var contentTypes = _httpContentFactories.SelectMany(x => x.SupportedContentTypes).Distinct().OrderBy(x => x).ToA |
| | 40 | 26 | | var selectListItems = new List<SelectListItem> { new("", "") }; |
| | | 27 | | |
| | 400 | 28 | | selectListItems.AddRange(contentTypes.Select(x => new SelectListItem(x, x))); |
| | | 29 | | |
| | 40 | 30 | | return new(selectListItems); |
| | | 31 | | } |
| | | 32 | | } |