Files
ersatztv/ErsatzTV/Formatters/ChannelGuideOutputFormatter.cs
T
Jason DoveandGitHub 1ab98578ab refactor namespaces and imports (#670)
* re-namespace

* optimize usings

* more usings

* more of the same

* more implicit/global usings

* cleanup all usings

* minor fixes
2022-03-03 15:36:07 -06:00

23 lines
820 B
C#

using System.Text;
using ErsatzTV.Core.Iptv;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Net.Http.Headers;
namespace ErsatzTV.Formatters;
public class ChannelGuideOutputFormatter : TextOutputFormatter
{
public ChannelGuideOutputFormatter()
{
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/xml"));
SupportedEncodings.Add(Encoding.UTF8);
SupportedEncodings.Add(Encoding.Unicode);
}
protected override bool CanWriteType(Type type) => typeof(ChannelGuide).IsAssignableFrom(type);
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) =>
// ReSharper disable once PossibleNullReferenceException
context.HttpContext.Response.WriteAsync(((ChannelGuide) context.Object).ToXml());
}