< Summary

Information
Class: Elsa.Http.Parsers.XmlHttpContentParser
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Parsers/XmlHttpContentParser.cs
Line coverage
18%
Covered lines: 2
Uncovered lines: 9
Coverable lines: 11
Total lines: 31
Line coverage: 18.1%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Priority()100%11100%
GetSupportsContentType(...)100%11100%
ReadAsync()0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Parsers/XmlHttpContentParser.cs

#LineLine coverage
 1using System.Xml.Serialization;
 2using Elsa.Http.Contexts;
 3
 4namespace Elsa.Http.Parsers;
 5
 6/// <summary>
 7/// Reads application/xml and text/xml content type streams.
 8/// </summary>
 9public class XmlHttpContentParser : IHttpContentParser
 10{
 11    /// <inheritdoc />
 20612    public int Priority => 0;
 13
 14    /// <inheritdoc />
 20015    public bool GetSupportsContentType(HttpResponseParserContext context) => context.ContentType.Contains("xml", StringC
 16
 17    /// <inheritdoc />
 18    public async Task<object> ReadAsync(HttpResponseParserContext context)
 19    {
 020        var content = context.Content;
 021        using var reader = new StreamReader(content, leaveOpen: true);
 022        var xml = await reader.ReadToEndAsync();
 023        var returnType = context.ReturnType;
 24
 025        if (returnType == null || returnType == typeof(string))
 026            return xml;
 27
 028        var serializer = new XmlSerializer(returnType);
 029        return serializer.Deserialize(reader)!;
 030    }
 31}