elsa-core/src/modules/Elsa.Http/ContentWriters/TextContentFactory.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

29 lines
836 B
C#

using System.Net.Mime;
using System.Text;
namespace Elsa.Http.ContentWriters;
/// <summary>
/// Creates a <see cref="StringContent"/> object for text/plain, text/richtext and text/html content types.
/// </summary>
public class TextContentFactory : IHttpContentFactory
{
/// <inheritdoc />
public IEnumerable<string> SupportedContentTypes => new[]
{
MediaTypeNames.Text.Plain,
MediaTypeNames.Text.RichText,
MediaTypeNames.Text.Html,
};
/// <inheritdoc />
public HttpContent CreateHttpContent(object content, string contentType)
{
var text = content as string ?? content.ToString();
if (string.IsNullOrWhiteSpace(contentType))
contentType = MediaTypeNames.Text.Plain;
return new StringContent(text!, Encoding.UTF8, contentType);
}
}