HttpRequestMessageExtensions.CreateContent<T> Method (HttpRequestMessage, T, MediaTypeHeaderValue, IEnumerable<MediaTypeFormatter>, IFormatterSelector)
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Creates a new ObjectContent instance associated with the given HttpRequestMessage.
Namespace: System.Net.Http
Assembly: System.Net.Http.Formatting (in System.Net.Http.Formatting.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function CreateContent(Of T) ( _
request As HttpRequestMessage, _
value As T, _
mediaType As MediaTypeHeaderValue, _
formatters As IEnumerable(Of MediaTypeFormatter), _
formatterSelector As IFormatterSelector _
) As ObjectContent(Of T)
public static ObjectContent<T> CreateContent<T>(
this HttpRequestMessage request,
T value,
MediaTypeHeaderValue mediaType,
IEnumerable<MediaTypeFormatter> formatters,
IFormatterSelector formatterSelector
)
[ExtensionAttribute]
public:
generic<typename T>
static ObjectContent<T>^ CreateContent(
HttpRequestMessage^ request,
T value,
MediaTypeHeaderValue^ mediaType,
IEnumerable<MediaTypeFormatter^>^ formatters,
IFormatterSelector^ formatterSelector
)
static member CreateContent :
request:HttpRequestMessage *
value:'T *
mediaType:MediaTypeHeaderValue *
formatters:IEnumerable<MediaTypeFormatter> *
formatterSelector:IFormatterSelector -> ObjectContent<'T>
JScript does not support generic types or methods.
Type Parameters
- T
The type of the value.
Parameters
- request
Type: System.Net.Http.HttpRequestMessage
The HttpRequestMessage.
- value
Type: T
The value for the new ObjectContent
- mediaType
Type: System.Net.Http.Headers.MediaTypeHeaderValue
The MediaTypeHeaderValue to set as the request media type.
- formatters
Type: System.Collections.Generic.IEnumerable<MediaTypeFormatter>
The collection of MediaTypeFormatter instances to use.
- formatterSelector
Type: System.Net.Http.Formatting.IFormatterSelector
The IFormatterSelector to select the MediaTypeFormatter
Return Value
Type: System.Net.Http.ObjectContent<T>
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type HttpRequestMessage. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.