OutputFormatterSelector.SelectFormatter 方法

定义

选择 , IOutputFormatter 以根据提供的值和当前请求写入响应。

public:
 abstract Microsoft::AspNetCore::Mvc::Formatters::IOutputFormatter ^ SelectFormatter(Microsoft::AspNetCore::Mvc::Formatters::OutputFormatterCanWriteContext ^ context, System::Collections::Generic::IList<Microsoft::AspNetCore::Mvc::Formatters::IOutputFormatter ^> ^ formatters, Microsoft::AspNetCore::Mvc::Formatters::MediaTypeCollection ^ mediaTypes);
public abstract Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter SelectFormatter (Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext context, System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter> formatters, Microsoft.AspNetCore.Mvc.Formatters.MediaTypeCollection mediaTypes);
public abstract Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter? SelectFormatter (Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext context, System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter> formatters, Microsoft.AspNetCore.Mvc.Formatters.MediaTypeCollection mediaTypes);
abstract member SelectFormatter : Microsoft.AspNetCore.Mvc.Formatters.OutputFormatterCanWriteContext * System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter> * Microsoft.AspNetCore.Mvc.Formatters.MediaTypeCollection -> Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter
Public MustOverride Function SelectFormatter (context As OutputFormatterCanWriteContext, formatters As IList(Of IOutputFormatter), mediaTypes As MediaTypeCollection) As IOutputFormatter

参数

context
OutputFormatterCanWriteContext

OutputFormatterCanWriteContext 当前请求关联的 。

formatters
IList<IOutputFormatter>

要使用的格式化程序列表;这充当对 的 OutputFormatters替代。

mediaTypes
MediaTypeCollection

要使用的媒体类型的列表;这充当标头的 Accept 替代。

返回

所选 IOutputFormatter的 ; null 如果无法选择,则为 。

适用于