public async Task <ActionResult> Index(string format) { var context = new FeedContext(this, format); var bestFormatterMatch = _feedFormatProviders .Select(provider => provider.Match(context)) .Where(match => match != null && match.FeedBuilder != null) .OrderByDescending(match => match.Priority) .FirstOrDefault(); if (bestFormatterMatch == null || bestFormatterMatch.FeedBuilder == null) { return(NotFound()); } context.Builder = bestFormatterMatch.FeedBuilder; var bestQueryMatch = _feedQueryProviders .Select(provider => provider.Match(context)) .Where(match => match != null && match.FeedQuery != null) .OrderByDescending(match => match.Priority) .FirstOrDefault(); if (bestQueryMatch == null || bestQueryMatch.FeedQuery == null) { return(NotFound()); } var document = await context.Builder.ProcessAsync(context, async() => { await bestQueryMatch.FeedQuery.ExecuteAsync(context); _feedItemBuilder.Populate(context); foreach (var contextualizer in context.Response.Contextualizers) { if (ControllerContext != null) { contextualizer(new ContextualizeContext { ServiceProvider = _serviceProvider, Url = Url }); } } }); return(Content(document.ToString(), "text/xml")); }
public ActionResult Index(string format) { var context = new FeedContext(ValueProvider, format); var bestFormatterMatch = _feedFormatProviders .Select(provider => provider.Match(context)) .Where(match => match != null && match.FeedBuilder != null) .OrderByDescending(match => match.Priority) .FirstOrDefault(); if (bestFormatterMatch == null || bestFormatterMatch.FeedBuilder == null) { return(HttpNotFound()); } context.Builder = bestFormatterMatch.FeedBuilder; var bestQueryMatch = _feedQueryProviders .Select(provider => provider.Match(context)) .Where(match => match != null && match.FeedQuery != null) .OrderByDescending(match => match.Priority) .FirstOrDefault(); if (bestQueryMatch == null || bestQueryMatch.FeedQuery == null) { return(HttpNotFound()); } return(context.Builder.Process(context, () => { bestQueryMatch.FeedQuery.Execute(context); _feedItemBuilder.Populate(context); foreach (var contextualizer in context.Response.Contextualizers) { if (ControllerContext != null && ControllerContext.RequestContext != null) { contextualizer(ControllerContext.RequestContext); } } })); }