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
@@ -22,7 +21,7 @@ public partial class Ids : IUrlParameter, IEquatable<Ids>
22
21
23
22
public Ids ( IList < Id > ids ) => _ids = ids ;
24
23
25
- public Ids ( IEnumerable < string > ids ) => _ids = ids ? . Select ( i => new Id ( i ) ) . ToList ( ) ;
24
+ public Ids ( IEnumerable < string > ids ) => _ids = ids . Select ( i => new Id ( i ) ) . ToList ( ) ;
26
25
27
26
public Ids ( string value )
28
27
{
@@ -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
- }
0 commit comments