Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpContentJsonExtensions.cs
Go to the documentation of this file.
2using System.IO;
3using System.Text;
9
10namespace System.Net.Http.Json;
11
12public static class HttpContentJsonExtensions
13{
14 [RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
16 {
17 if (content == null)
18 {
19 throw new ArgumentNullException("content");
20 }
21 Encoding encoding = JsonHelpers.GetEncoding(content.Headers.ContentType?.CharSet);
22 return ReadFromJsonAsyncCore(content, type, encoding, options, cancellationToken);
23 }
24
25 [RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
27 {
28 if (content == null)
29 {
30 throw new ArgumentNullException("content");
31 }
32 Encoding encoding = JsonHelpers.GetEncoding(content.Headers.ContentType?.CharSet);
33 return ReadFromJsonAsyncCore<T>(content, encoding, options, cancellationToken);
34 }
35
36 [RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
38 {
40 {
42 }
43 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Workaround for https://github.com/mono/linker/issues/1416. The outer method is marked as RequiresUnreferencedCode.")]
44 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern", Justification = "Workaround for https://github.com/mono/linker/issues/1416. The outer method is marked as RequiresUnreferencedCode.")]
46 {
48 }
49 }
50
51 [RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
57
58 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Workaround for https://github.com/mono/linker/issues/1416. The outer method is marked as RequiresUnreferencedCode.")]
59 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2091:UnrecognizedReflectionPattern", Justification = "Workaround for https://github.com/mono/linker/issues/1416. The outer method is marked as RequiresUnreferencedCode.")]
64
66 {
67 if (content == null)
68 {
69 throw new ArgumentNullException("content");
70 }
71 Encoding encoding = JsonHelpers.GetEncoding(content.Headers.ContentType?.CharSet);
72 return ReadFromJsonAsyncCore(content, type, encoding, context, cancellationToken);
73 }
74
76 {
77 if (content == null)
78 {
79 throw new ArgumentNullException("content");
80 }
81 Encoding encoding = JsonHelpers.GetEncoding(content.Headers.ContentType?.CharSet);
82 return ReadFromJsonAsyncCore(content, encoding, jsonTypeInfo, cancellationToken);
83 }
84
90
96
106
111
116}
Task< Stream > ReadAsStreamAsync()
HttpContentHeaders Headers
static async Task< T > ReadFromJsonAsyncCore< T >(HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
static ValueTask< TValue > DeserializeAsyncHelper< TValue >(Stream contentStream, JsonSerializerOptions options, CancellationToken cancellationToken)
static async Task< Stream > GetContentStream(HttpContent content, Encoding sourceEncoding, CancellationToken cancellationToken)
static async Task< object > ReadFromJsonAsyncCore(HttpContent content, Type type, Encoding sourceEncoding, JsonSerializerContext context, CancellationToken cancellationToken)
static Task< object?> ReadFromJsonAsync(this HttpContent content, Type type, JsonSerializerOptions? options=null, CancellationToken cancellationToken=default(CancellationToken))
static Stream GetTranscodingStream(Stream contentStream, Encoding sourceEncoding)
static Task< T?> ReadFromJsonAsync< T >(this HttpContent content, JsonSerializerOptions? options=null, CancellationToken cancellationToken=default(CancellationToken))
static async Task< object > ReadFromJsonAsyncCore(HttpContent content, Type type, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
static Task< Stream > ReadHttpContentStreamAsync(HttpContent content, CancellationToken cancellationToken)
static Task< object?> ReadFromJsonAsync(this HttpContent content, Type type, JsonSerializerContext context, CancellationToken cancellationToken=default(CancellationToken))
static Encoding GetEncoding(string charset)
static readonly JsonSerializerOptions s_defaultSerializerOptions
Definition JsonHelpers.cs:9
static Encoding UTF8
Definition Encoding.cs:526
static Stream CreateTranscodingStream(Stream innerStream, Encoding innerStreamEncoding, Encoding outerStreamEncoding, bool leaveOpen=false)
Definition Encoding.cs:1046
static ValueTask< object?> DeserializeAsync(Stream utf8Json, Type returnType, JsonSerializerOptions? options=null, CancellationToken cancellationToken=default(CancellationToken))