OutputFormatter Class¶
Inheritance Hierarchy¶
System.Object
Microsoft.AspNet.Mvc.OutputFormatter
Syntax¶
public abstract class OutputFormatter : IOutputFormatter, IApiResponseFormatMetadataProvider
Constructors¶
-
Microsoft.AspNet.Mvc.OutputFormatter.OutputFormatter()
Initializes a new instance of the [Microsoft.AspNet.Mvc.OutputFormatter](Microsoft.AspNet.Mvc.OutputFormatter.yml) class.
protected OutputFormatter()
-
Properties¶
-
SupportedEncodings
()¶ Gets the mutable collection of character encodings supported by this [Microsoft.AspNet.Mvc.OutputFormatter](Microsoft.AspNet.Mvc.OutputFormatter.yml). The encodings are used when writing the data.
Return type: System.Collections.Generic.IList{System.Text.Encoding} public IList<Encoding> SupportedEncodings { get; }
-
SupportedMediaTypes
()¶ Gets the mutable collection of @!:MediaTypeHeaderValue- elements supported by this [Microsoft.AspNet.Mvc.OutputFormatter](Microsoft.AspNet.Mvc.OutputFormatter.yml).
Return type: System.Collections.Generic.IList{MediaTypeHeaderValue} public IList<MediaTypeHeaderValue> SupportedMediaTypes { get; }
-
Methods¶
-
CanWriteResult
(Microsoft.AspNet.Mvc.OutputFormatterContext, MediaTypeHeaderValue)¶ Arguments: - context (Microsoft.AspNet.Mvc.OutputFormatterContext) –
- contentType (MediaTypeHeaderValue) –
Return type: System.Boolean
public virtual bool CanWriteResult(OutputFormatterContext context, MediaTypeHeaderValue contentType)
-
CanWriteType
(System.Type, System.Type)¶ Returns a value indicating whether or not the given type can be written by this serializer.
Arguments: - declaredType (System.Type) – The declared type.
- runtimeType (System.Type) – The runtime type.
Return type: System.Boolean
Returns: <c>true</c> if the type can be written, otherwise <c>false</c>.
protected virtual bool CanWriteType(Type declaredType, Type runtimeType)
-
GetSupportedContentTypes
(System.Type, System.Type, MediaTypeHeaderValue)¶ Arguments: - declaredType (System.Type) –
- runtimeType (System.Type) –
- contentType (MediaTypeHeaderValue) –
Return type: System.Collections.Generic.IReadOnlyList{MediaTypeHeaderValue}
public virtual IReadOnlyList<MediaTypeHeaderValue> GetSupportedContentTypes(Type declaredType, Type runtimeType, MediaTypeHeaderValue contentType)
-
SelectCharacterEncoding
(Microsoft.AspNet.Mvc.OutputFormatterContext)¶ Determines the best [System.Text.Encoding]() amongst the supported encodings for reading or writing an HTTP entity body based on the provided <paramref name=”contentTypeHeader” />.
Arguments: - context (Microsoft.AspNet.Mvc.OutputFormatterContext) – The formatter context associated with the call.
Return type: System.Text.Encoding
Returns: The [System.Text.Encoding]() to use when reading the request or writing the response.
public virtual Encoding SelectCharacterEncoding(OutputFormatterContext context)
-
WriteAsync
(Microsoft.AspNet.Mvc.OutputFormatterContext)¶ Arguments: - context (Microsoft.AspNet.Mvc.OutputFormatterContext) –
Return type: System.Threading.Tasks.Task
public Task WriteAsync(OutputFormatterContext context)
-
WriteResponseBodyAsync
(Microsoft.AspNet.Mvc.OutputFormatterContext)¶ Writes the response body.
Arguments: - context (Microsoft.AspNet.Mvc.OutputFormatterContext) – The formatter context associated with the call.
Return type: System.Threading.Tasks.Task
Returns: A task which can write the response body.
public abstract Task WriteResponseBodyAsync(OutputFormatterContext context)
-
WriteResponseHeaders
(Microsoft.AspNet.Mvc.OutputFormatterContext)¶ Sets the headers on @!:Microsoft.AspNet.Http.HttpResponse- object.
Arguments: - context (Microsoft.AspNet.Mvc.OutputFormatterContext) – The formatter context associated with the call.
public virtual void WriteResponseHeaders(OutputFormatterContext context)
-