@@ -113,12 +113,12 @@ public int SetFromDirectory(RedisValue path, string filesPath, When when = When.
113113
114114 if ( result . IsNull )
115115 {
116- return Array . Empty < bool ? > ( ) ;
116+ return [ ] ;
117117 }
118118
119- if ( result . Type == ResultType . Integer )
119+ if ( result . Resp2Type == ResultType . Integer )
120120 {
121- return new bool ? [ ] { ( long ) result == 1 } ;
121+ return [ ( long ) result == 1 ] ;
122122 }
123123
124124 return ( ( RedisResult [ ] ) result ! ) . Select ( x => ( bool ? ) ( ( long ) x == 1 ) ) . ToArray ( ) ;
@@ -129,18 +129,14 @@ public JsonType[] Type(RedisKey key, string? path = null)
129129 {
130130 RedisResult result = _db . Execute ( JsonCommandBuilder . Type ( key , path ) ) ;
131131
132- if ( result . Type == ResultType . MultiBulk )
132+ return result . Resp2Type switch
133133 {
134- return ( ( RedisResult [ ] ) result ! ) . Select ( x => ( JsonType ) Enum . Parse ( typeof ( JsonType ) , x . ToString ( ) ! . ToUpper ( ) ) ) . ToArray ( ) ;
135- }
136-
137- if ( result . Type == ResultType . BulkString )
138- {
139- return new [ ] { ( JsonType ) Enum . Parse ( typeof ( JsonType ) , result . ToString ( ) ! . ToUpper ( ) ) } ;
140- }
141-
142- return Array . Empty < JsonType > ( ) ;
143-
134+ ResultType . Array => ( ( RedisResult [ ] ) result ! )
135+ . Select ( x => ( JsonType ) Enum . Parse ( typeof ( JsonType ) , x . ToString ( ) ! . ToUpper ( ) ) )
136+ . ToArray ( ) ,
137+ ResultType . BulkString => new [ ] { ( JsonType ) Enum . Parse ( typeof ( JsonType ) , result . ToString ( ) ! . ToUpper ( ) ) } ,
138+ _ => [ ]
139+ } ;
144140 }
145141
146142 public long DebugMemory ( string key , string ? path = null )
@@ -177,17 +173,12 @@ public RedisResult[] ArrPop(RedisKey key, string? path = null, long? index = nul
177173 {
178174 RedisResult result = _db . Execute ( JsonCommandBuilder . ArrPop ( key , path , index ) ) ;
179175
180- if ( result . Type == ResultType . MultiBulk )
176+ return result . Resp2Type switch
181177 {
182- return ( RedisResult [ ] ) result ! ;
183- }
184-
185- if ( result . Type == ResultType . BulkString )
186- {
187- return new [ ] { result } ;
188- }
189-
190- return Array . Empty < RedisResult > ( ) ;
178+ ResultType . Array => ( RedisResult [ ] ) result ! ,
179+ ResultType . BulkString => new [ ] { result } ,
180+ _ => [ ]
181+ } ;
191182 }
192183
193184 /// <inheritdoc/>
@@ -224,10 +215,10 @@ public RedisResult Get(RedisKey key, string[] paths, RedisValue? indent = null,
224215 }
225216
226217 /// <inheritdoc/>
227- public T ? Get < T > ( RedisKey key , string path = "$" , JsonSerializerOptions ? serializerOptions = default )
218+ public T ? Get < T > ( RedisKey key , string path = "$" , JsonSerializerOptions ? serializerOptions = null )
228219 {
229220 var res = _db . Execute ( JsonCommandBuilder . Get < T > ( key , path ) ) ;
230- if ( res . Type == ResultType . BulkString && ! res . IsNull )
221+ if ( res . Resp2Type == ResultType . BulkString && ! res . IsNull )
231222 {
232223 var arr = JsonSerializer . Deserialize < JsonArray > ( res . ToString ( ) ! ) ;
233224 if ( arr ? . Count > 0 )
0 commit comments