* 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
33 lines
918 B
C#
33 lines
918 B
C#
using System.Net.Mime;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace Elsa.Http.ContentWriters;
|
|
|
|
/// <summary>
|
|
/// Creates a <see cref="HttpContent"/> object for XML types.
|
|
/// </summary>
|
|
public class XmlContentFactory : IHttpContentFactory
|
|
{
|
|
/// <inheritdoc />
|
|
public IEnumerable<string> SupportedContentTypes => new[]
|
|
{
|
|
MediaTypeNames.Application.Xml,
|
|
MediaTypeNames.Text.Xml,
|
|
MediaTypeNames.Application.Soap,
|
|
};
|
|
|
|
/// <inheritdoc />
|
|
public HttpContent CreateHttpContent(object content, string contentType)
|
|
{
|
|
var text = content as string ?? Serialize(content);
|
|
return new StringContent(text, Encoding.UTF8, contentType);
|
|
}
|
|
|
|
private string Serialize(object value)
|
|
{
|
|
using var writer = new StringWriter();
|
|
new XmlSerializer(value.GetType()).Serialize(writer, value);
|
|
return writer.ToString();
|
|
}
|
|
} |