Replace Linq in hotpath (#5024)
This commit is contained in:
parent
ea73434979
commit
8ec27958e7
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||||
using Microsoft.AspNetCore.Mvc.Core;
|
using Microsoft.AspNetCore.Mvc.Core;
|
||||||
|
|
@ -87,10 +86,17 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
{
|
{
|
||||||
// Check if there are any IFormatFilter in the pipeline, and if any of them is active. If there is one,
|
// Check if there are any IFormatFilter in the pipeline, and if any of them is active. If there is one,
|
||||||
// do not override the content type value.
|
// do not override the content type value.
|
||||||
if (context.Filters.OfType<IFormatFilter>().All(f => f.GetFormat(context) == null))
|
for (var i = 0; i < context.Filters.Count; i++)
|
||||||
{
|
{
|
||||||
SetContentTypes(objectResult.ContentTypes);
|
var filter = context.Filters[i] as IFormatFilter;
|
||||||
|
|
||||||
|
if (filter?.GetFormat(context) != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetContentTypes(objectResult.ContentTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue