Skip to content

Commit 6831d2d

Browse files
committed
Removed separate deserialization of BaseResponse's through ToParsedResponse, everything flows to Deserialize noticed after writing PR notes for #349
1 parent 757b279 commit 6831d2d

36 files changed

+85
-73
lines changed

src/Nest.Tests.Integration/IntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected IQueryResponse<T> SearchRaw<T>(string query) where T : class
3636
var index = this._client.GetIndexNameFor<T>();
3737
var typeName = this._client.GetTypeNameFor<T>();
3838
var connectionStatus = this._client.Raw.SearchPost(index, typeName, query);
39-
return connectionStatus.ToParsedResponse<QueryResponse<T>>();
39+
return connectionStatus.Deserialize<QueryResponse<T>>();
4040
}
4141

4242
public void DoFilterTest(Func<FilterDescriptor<ElasticSearchProject>, Nest.BaseFilter> filter, ElasticSearchProject project, bool queryMustHaveResults)

src/Nest/Domain/Connection/ConnectionStatus.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ public ConnectionStatus(IConnectionSettings settings, string result) : this(sett
6161
/// Returns a response of type R based on the connection status by trying parsing status.Result into R
6262
/// </summary>
6363
/// <returns></returns>
64-
public virtual R ToParsedResponse<R>(bool allow404 = false, IEnumerable<JsonConverter> extraConverters = null) where R : BaseResponse
64+
public virtual T Deserialize<T>(IEnumerable<JsonConverter> extraConverters = null, bool allow404 = false) where T : class
6565
{
66-
return this._elasticSerializer.ToParsedResponse<R>(this, allow404, extraConverters);
66+
if (typeof(BaseResponse).IsAssignableFrom(typeof(T)))
67+
return this._elasticSerializer.Deserialize<T>(this, extraConverters, allow404);
68+
return this._elasticSerializer.Deserialize<T>(this.Result, extraConverters, allow404);
6769
}
6870

6971
public override string ToString()

src/Nest/ElasticClient-Aliases.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private IndicesOperationResponse _Alias(string query)
202202
query = _aliasBody.F(query);
203203
var status = this.Connection.PostSync(path, query);
204204

205-
var r = this.ToParsedResponse<IndicesOperationResponse>(status);
205+
var r = this.Deserialize<IndicesOperationResponse>(status);
206206
return r;
207207
}
208208
}

src/Nest/ElasticClient-Analyze.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private AnalyzeResponse _Analyze(AnalyzeParams analyzeParams, string text)
6464
}
6565

6666
var status = this.Connection.GetSync(path);
67-
var r = this.ToParsedResponse<AnalyzeResponse>(status);
67+
var r = this.Deserialize<AnalyzeResponse>(status);
6868
return r;
6969
}
7070
}

src/Nest/ElasticClient-Bulk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public IBulkResponse Bulk(BulkDescriptor bulkDescriptor)
6666
path = bulkDescriptor._FixedIndex + "/" + path;
6767
}
6868
var status = this.Connection.PostSync(path, json);
69-
return this.ToParsedResponse<BulkResponse>(status);
69+
return this.Deserialize<BulkResponse>(status);
7070
}
7171

7272
internal string GenerateBulkIndexCommand<T>(IEnumerable<T> objects) where T : class

src/Nest/ElasticClient-Count.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public ICountResponse Count<T>(IEnumerable<string> indices, IEnumerable<string>
127127
private CountResponse _Count(string path, string query)
128128
{
129129
var status = this.Connection.PostSync(path, query);
130-
var r = this.ToParsedResponse<CountResponse>(status);
130+
var r = this.Deserialize<CountResponse>(status);
131131
return r;
132132
}
133133

src/Nest/ElasticClient-CreateIndex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public IIndicesOperationResponse CreateIndex(string index, IndexSettings setting
1818
string data = this.Serialize(settings);
1919
string path = this.PathResolver.CreateIndexPath(index);
2020
var status = this.Connection.PostSync(path, data);
21-
return this.ToParsedResponse<IndicesOperationResponse>(status);
21+
return this.Deserialize<IndicesOperationResponse>(status);
2222
}
2323

2424
/// <summary>

src/Nest/ElasticClient-Delete.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,41 +119,41 @@ private IDeleteResponse _deleteToPath(string path)
119119
{
120120
path.ThrowIfNull("path");
121121
var status = this.Connection.DeleteSync(path);
122-
return this.ToParsedResponse<DeleteResponse>(status);
122+
return this.Deserialize<DeleteResponse>(status);
123123
}
124124

125125
private IDeleteResponse _deleteToPath(string path, string data)
126126
{
127127
path.ThrowIfNull("path");
128128
var status = this.Connection.DeleteSync(path, data);
129-
return this.ToParsedResponse<DeleteResponse>(status);
129+
return this.Deserialize<DeleteResponse>(status);
130130
}
131131

132132
private IBulkResponse _deleteToBulkPath(string path, string data)
133133
{
134134
path.ThrowIfNull("path");
135135
var status = this.Connection.PostSync(path, data);
136-
return this.ToParsedResponse<BulkResponse>(status);
136+
return this.Deserialize<BulkResponse>(status);
137137
}
138138

139139
private Task<IDeleteResponse> _deleteToPathAsync(string path)
140140
{
141141
path.ThrowIfNull("path");
142142
var task = this.Connection.Delete(path);
143-
return task.ContinueWith<IDeleteResponse>(t => this.ToParsedResponse<DeleteResponse>(t.Result));
143+
return task.ContinueWith<IDeleteResponse>(t => this.Deserialize<DeleteResponse>(t.Result));
144144
}
145145

146146
private Task<IDeleteResponse> _deleteToPathAsync(string path, string data)
147147
{
148148
path.ThrowIfNull("path");
149149
var task = this.Connection.Delete(path, data);
150-
return task.ContinueWith<IDeleteResponse>(t => this.ToParsedResponse<DeleteResponse>(t.Result));
150+
return task.ContinueWith<IDeleteResponse>(t => this.Deserialize<DeleteResponse>(t.Result));
151151
}
152152
private Task<IBulkResponse> _deleteToBulkPathAsync(string path, string data)
153153
{
154154
path.ThrowIfNull("path");
155155
var task = this.Connection.Post(path, data);
156-
return task.ContinueWith<IBulkResponse>(t => this.ToParsedResponse<BulkResponse>(t.Result));
156+
return task.ContinueWith<IBulkResponse>(t => this.Deserialize<BulkResponse>(t.Result));
157157
}
158158
}
159159
}

src/Nest/ElasticClient-Flush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public IIndicesOperationResponse Flush(IEnumerable<string> indices, bool refresh
5252
private IndicesOperationResponse _Flush(string path)
5353
{
5454
var status = this.Connection.PostSync(path, "");
55-
var r = this.ToParsedResponse<IndicesOperationResponse>(status);
55+
var r = this.Deserialize<IndicesOperationResponse>(status);
5656
return r;
5757
}
5858
}

src/Nest/ElasticClient-GetFull.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public IGetResponse<T> GetFull<T>(Action<GetDescriptor<T>> getSelector) where T
6868
private IGetResponse<T> _GetFull<T>(string path) where T : class
6969
{
7070
var response = this.Connection.GetSync(path);
71-
var getResponse = this.ToParsedResponse<GetResponse<T>>(response);
71+
var getResponse = this.Deserialize<GetResponse<T>>(response);
7272

7373
if (response.Result != null)
7474
{

0 commit comments

Comments
 (0)