11using Elasticsearch . Net ;
22using System ;
33using System . Collections . Generic ;
4+ using System . IO ;
45using System . Linq ;
56using System . Text ;
67using System . Threading . Tasks ;
78
89namespace Nest
910{
11+ using PingConverter = Func < IElasticsearchResponse , Stream , PingResponse > ;
12+
1013 public partial class ElasticClient
1114 {
1215 /// <inheritdoc />
@@ -15,7 +18,9 @@ public IPingResponse Ping(Func<PingDescriptor, PingDescriptor> pingSelector = nu
1518 pingSelector = pingSelector ?? ( s => s ) ;
1619 return this . Dispatch < PingDescriptor , PingRequestParameters , PingResponse > (
1720 pingSelector ,
18- ( p , d ) => this . RawDispatch . PingDispatch < PingResponse > ( p )
21+ ( p , d ) => this . RawDispatch . PingDispatch < PingResponse > (
22+ p . DeserializationState ( new PingConverter ( DeserializePingResponse ) )
23+ )
1924 ) ;
2025 }
2126
@@ -25,7 +30,9 @@ public Task<IPingResponse> PingAsync(Func<PingDescriptor, PingDescriptor> pingSe
2530 pingSelector = pingSelector ?? ( s => s ) ;
2631 return this . DispatchAsync < PingDescriptor , PingRequestParameters , PingResponse , IPingResponse > (
2732 pingSelector ,
28- ( p , d ) => this . RawDispatch . PingDispatchAsync < PingResponse > ( p )
33+ ( p , d ) => this . RawDispatch . PingDispatchAsync < PingResponse > (
34+ p . DeserializationState ( new PingConverter ( DeserializePingResponse ) )
35+ )
2936 ) ;
3037 }
3138
@@ -34,7 +41,9 @@ public IPingResponse Ping(IPingRequest pingRequest)
3441 {
3542 return this . Dispatch < IPingRequest , PingRequestParameters , PingResponse > (
3643 pingRequest ,
37- ( p , d ) => this . RawDispatch . PingDispatch < PingResponse > ( p )
44+ ( p , d ) => this . RawDispatch . PingDispatch < PingResponse > (
45+ p . DeserializationState ( new PingConverter ( DeserializePingResponse ) )
46+ )
3847 ) ;
3948 }
4049
@@ -43,8 +52,15 @@ public Task<IPingResponse> PingAsync(IPingRequest pingRequest)
4352 {
4453 return this . DispatchAsync < IPingRequest , PingRequestParameters , PingResponse , IPingResponse > (
4554 pingRequest ,
46- ( p , d ) => this . RawDispatch . PingDispatchAsync < PingResponse > ( p )
55+ ( p , d ) => this . RawDispatch . PingDispatchAsync < PingResponse > (
56+ p . DeserializationState ( new PingConverter ( DeserializePingResponse ) )
57+ )
4758 ) ;
4859 }
60+
61+ private PingResponse DeserializePingResponse ( IElasticsearchResponse response , Stream stream )
62+ {
63+ return new PingResponse ( response ) ;
64+ }
4965 }
5066}
0 commit comments