Skip to content

Commit a5eebec

Browse files
committed
Merge branch 'develop' of github.com:elasticsearch/elasticsearch-net into develop
2 parents 1a5f915 + 4fcecae commit a5eebec

File tree

10 files changed

+1049
-1075
lines changed

10 files changed

+1049
-1075
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiEndpoint.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
213213
QueryStringParamName = queryStringParamName,
214214
ReturnType = string.Format("ElasticsearchResponse<{0}>", defaultBoundGeneric),
215215
ReturnTypeGeneric = null,
216-
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
217-
CallTypeGeneric = defaultBoundGeneric,
216+
CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary"
217+
? "Dictionary<string, object>" : defaultBoundGeneric,
218218
ReturnDescription =
219219
"ElasticsearchResponse&lt;T&gt; holding the response body deserialized as DynamicDictionary"
220220
+ explanationOfDynamic,
@@ -234,8 +234,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
234234
QueryStringParamName = queryStringParamName,
235235
ReturnType = string.Format("Task<ElasticsearchResponse<{0}>>", defaultBoundGeneric),
236236
ReturnTypeGeneric = null,
237-
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
238-
CallTypeGeneric = defaultBoundGeneric,
237+
CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary"
238+
? "Dictionary<string, object>" : defaultBoundGeneric,
239239
ReturnDescription =
240240
"Task that'll return an ElasticsearchResponse&lt;T$gt; holding the response body deserialized as DynamicDictionary"
241241
+ explanationOfDynamic,

src/Elasticsearch.Net/Domain/Response/ElasticsearchResponse.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,26 @@ namespace Elasticsearch.Net
2222
// TODO: Make this class internal in 2.0
2323
public static class ElasticsearchResponse
2424
{
25-
internal static ElasticsearchResponse<TTo> CloneFrom<TTo>(IElasticsearchResponse from, TTo to)
25+
public static Task<ElasticsearchResponse<DynamicDictionary>> WrapAsync(Task<ElasticsearchResponse<Dictionary<string, object>>> responseTask)
26+
{
27+
return responseTask
28+
.ContinueWith(t =>
29+
{
30+
if (t.IsFaulted && t.Exception != null)
31+
{
32+
t.Exception.Flatten().InnerException.RethrowKeepingStackTrace();
33+
return null; //won't be hit
34+
}
35+
return ToDynamicResponse(t.Result);
36+
});
37+
}
38+
39+
public static ElasticsearchResponse<DynamicDictionary> Wrap(ElasticsearchResponse<Dictionary<string, object>> response)
40+
{
41+
return ToDynamicResponse(response);
42+
}
43+
44+
public static ElasticsearchResponse<TTo> CloneFrom<TTo>(IElasticsearchResponse from, TTo to)
2645
{
2746
var response = new ElasticsearchResponse<TTo>(from.Settings)
2847
{
@@ -43,6 +62,11 @@ internal static ElasticsearchResponse<TTo> CloneFrom<TTo>(IElasticsearchResponse
4362
tt.RequestInformation = response;
4463
return response;
4564
}
65+
66+
public static ElasticsearchResponse<DynamicDictionary> ToDynamicResponse(ElasticsearchResponse<Dictionary<string, object>> response)
67+
{
68+
return CloneFrom(response, response.Response != null ? DynamicDictionary.Create(response.Response) : null);
69+
}
4670
}
4771

4872
public class ElasticsearchResponse<T> : IElasticsearchResponse

0 commit comments

Comments
 (0)