File tree 2 files changed +49
-40
lines changed
src/Elastic.Clients.Elasticsearch/Core/Infer/Id
2 files changed +49
-40
lines changed Original file line number Diff line number Diff line change 6
6
using System . Collections . Generic ;
7
7
using System . Diagnostics ;
8
8
using System . Linq ;
9
- using System . Text . Json ;
10
9
using System . Text . Json . Serialization ;
11
10
using Elastic . Transport ;
12
11
@@ -84,42 +83,3 @@ public override int GetHashCode()
84
83
85
84
public static bool operator != ( Ids left , Ids right ) => ! Equals ( left , right ) ;
86
85
}
87
-
88
- internal sealed class IdsConverter : JsonConverter < Ids >
89
- {
90
- public override Ids ? Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
91
- {
92
- if ( reader . TokenType != JsonTokenType . StartArray )
93
- throw new JsonException ( $ "Unexpected JSON token. Expected { JsonTokenType . StartArray } but read { reader . TokenType } ") ;
94
-
95
- var ids = new List < Id > ( ) ;
96
-
97
- while ( reader . Read ( ) && reader . TokenType != JsonTokenType . EndArray )
98
- {
99
- var id = JsonSerializer . Deserialize < Id > ( ref reader , options ) ;
100
-
101
- if ( id is not null )
102
- ids . Add ( id ) ;
103
- }
104
-
105
- return new Ids ( ids ) ;
106
- }
107
-
108
- public override void Write ( Utf8JsonWriter writer , Ids value , JsonSerializerOptions options )
109
- {
110
- if ( value is null )
111
- {
112
- writer . WriteNullValue ( ) ;
113
- return ;
114
- }
115
-
116
- writer . WriteStartArray ( ) ;
117
-
118
- foreach ( var id in value . IdsToSerialize )
119
- {
120
- JsonSerializer . Serialize < Id > ( writer , id , options ) ;
121
- }
122
-
123
- writer . WriteEndArray ( ) ;
124
- }
125
- }
Original file line number Diff line number Diff line change
1
+ // Licensed to Elasticsearch B.V under one or more agreements.
2
+ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ // See the LICENSE file in the project root for more information.
4
+
5
+ using System ;
6
+ using System . Collections . Generic ;
7
+ using System . Text . Json ;
8
+ using System . Text . Json . Serialization ;
9
+
10
+ namespace Elastic . Clients . Elasticsearch ;
11
+
12
+ internal sealed class IdsConverter : JsonConverter < Ids >
13
+ {
14
+ public override Ids ? Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
15
+ {
16
+ if ( reader . TokenType != JsonTokenType . StartArray )
17
+ throw new JsonException ( $ "Unexpected JSON token. Expected { JsonTokenType . StartArray } but read { reader . TokenType } ") ;
18
+
19
+ var ids = new List < Id > ( ) ;
20
+
21
+ while ( reader . Read ( ) && reader . TokenType != JsonTokenType . EndArray )
22
+ {
23
+ var id = JsonSerializer . Deserialize < Id > ( ref reader , options ) ;
24
+
25
+ if ( id is not null )
26
+ ids . Add ( id ) ;
27
+ }
28
+
29
+ return new Ids ( ids ) ;
30
+ }
31
+
32
+ public override void Write ( Utf8JsonWriter writer , Ids value , JsonSerializerOptions options )
33
+ {
34
+ if ( value is null )
35
+ {
36
+ writer . WriteNullValue ( ) ;
37
+ return ;
38
+ }
39
+
40
+ writer . WriteStartArray ( ) ;
41
+
42
+ foreach ( var id in value . IdsToSerialize )
43
+ {
44
+ JsonSerializer . Serialize < Id > ( writer , id , options ) ;
45
+ }
46
+
47
+ writer . WriteEndArray ( ) ;
48
+ }
49
+ }
You can’t perform that action at this time.
0 commit comments