public async Task <IActionResult> Rss([FromServices] IEnumerable <IChannelProvider> channelProviders = null)
        {
            channelProviders = channelProviders ?? new List <IChannelProvider>();
            var list = channelProviders as List <IChannelProvider>;

            if (list?.Count == 0)
            {
                list.Add(new NullChannelProvider());
            }

            var channelResolver = new DefaultChannelProviderResolver();
            var xmlFormatter    = new DefaultXmlFormatter();

            var currentChannelProvider = channelResolver.GetCurrentChannelProvider(channelProviders);

            if (currentChannelProvider == null)
            {
                Response.StatusCode = 404;
                return(new EmptyResult());
            }

            var currentChannel = await currentChannelProvider.GetChannel();

            if (currentChannel == null)
            {
                Response.StatusCode = 404;
                return(new EmptyResult());
            }

            var xml = xmlFormatter.BuildXml(currentChannel);

            return(new XmlResult(xml));
        }
Beispiel #2
0
        public async Task <ActionResult> Get(string id)
        {
            var currentChannel = await feed.GetChannel();

            var xmlFormatter = new DefaultXmlFormatter();
            var xml          = xmlFormatter.BuildXml(currentChannel);

            return(new XmlResult(xml));
        }