-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathJsonConverters.BatchObjectNullable.g.cs
More file actions
60 lines (55 loc) · 2.11 KB
/
JsonConverters.BatchObjectNullable.g.cs
File metadata and controls
60 lines (55 loc) · 2.11 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
50
51
52
53
54
55
56
57
58
59
60
#nullable enable
namespace tryAGI.OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class BatchObjectNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::tryAGI.OpenAI.BatchObject?>
{
/// <inheritdoc />
public override global::tryAGI.OpenAI.BatchObject? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::tryAGI.OpenAI.BatchObjectExtensions.ToEnum(stringValue);
}
break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::tryAGI.OpenAI.BatchObject)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::tryAGI.OpenAI.BatchObject?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}
return default;
}
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::tryAGI.OpenAI.BatchObject? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));
if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::tryAGI.OpenAI.BatchObjectExtensions.ToValueString(value.Value));
}
}
}
}