forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectContentOfT.cs
More file actions
49 lines (45 loc) · 2.4 KB
/
Copy pathObjectContentOfT.cs
File metadata and controls
49 lines (45 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
namespace System.Net.Http
{
/// <summary>
/// Generic form of <see cref="ObjectContent"/>.
/// </summary>
/// <typeparam name="T">The type of object this <see cref="ObjectContent"/> class will contain.</typeparam>
public class ObjectContent<T> : ObjectContent
{
/// <summary>
/// Initializes a new instance of the <see cref="ObjectContent{T}"/> class.
/// </summary>
/// <param name="value">The value of the object this instance will contain.</param>
/// <param name="formatter">The formatter to use when serializing the value.</param>
public ObjectContent(T value, MediaTypeFormatter formatter)
: this(value, formatter, (MediaTypeHeaderValue)null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ObjectContent{T}"/> class.
/// </summary>
/// <param name="value">The value of the object this instance will contain.</param>
/// <param name="formatter">The formatter to use when serializing the value.</param>
/// <param name="mediaType">The authoritative value of the content's Content-Type header. Can be <c>null</c> in which case the
/// <paramref name="formatter">formatter's</paramref> default content type will be used.</param>
public ObjectContent(T value, MediaTypeFormatter formatter, string mediaType)
: this(value, formatter, BuildHeaderValue(mediaType))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ObjectContent{T}"/> class.
/// </summary>
/// <param name="value">The value of the object this instance will contain.</param>
/// <param name="formatter">The formatter to use when serializing the value.</param>
/// <param name="mediaType">The authoritative value of the content's Content-Type header. Can be <c>null</c> in which case the
/// <paramref name="formatter">formatter's</paramref> default content type will be used.</param>
public ObjectContent(T value, MediaTypeFormatter formatter, MediaTypeHeaderValue mediaType)
: base(typeof(T), value, formatter, mediaType)
{
}
}
}