elsa-core/src/modules/Elsa.Http/ContentWriters/XmlContentFactory.cs
gurkanguran 407bfa6913
Use workflow definition as activity (#3654)
* Implemented usage of workflow definitions as activities

* Updated designer

* Removed activity definitions module

* Allow user to mark workflow to be used as activity

* Refactor

* Refactor

* Cleanup csproj

* Cleanup WorkflowDefinitionActivity

* Pascalize typename

* Fix JS intellisense initial load issue

* Add XML comments

* Add Jobs dependency

* Hide Composite root port from designer

* Move finding workflow activities logic to lower level

* Generate unique identities across hierarchy

* Refactor

* Revert "Generate unique identities across hierarchy"

This reverts commit 74f5e7830309ee76af6ab3a000a5e1ec41f1e90c.

* Implement unique node IDs

* Introduce new VersionOptions option

* Remove unused namespaces

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-01-28 00:36:03 +01:00

30 lines
972 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 application/json.
/// </summary>
public class XmlContentFactory : IHttpContentFactory
{
private readonly List<string> _supportedContentTypes = new() { MediaTypeNames.Application.Xml, MediaTypeNames.Text.Xml };
/// <inheritdoc />
public bool SupportsContentType(string contentType) => _supportedContentTypes.Contains(contentType);
/// <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();
}
}