summaryrefslogtreecommitdiff
path: root/FireBase/Http
diff options
context:
space:
mode:
authorTrueKuehli <rctcoaster2000@hotmail.de>2018-10-07 12:05:11 +0200
committerTrueKuehli <rctcoaster2000@hotmail.de>2018-10-07 12:05:11 +0200
commit97f19926ac2b02e976c1abf993525b519d68ffac (patch)
tree60fb48ecf30b70530d6132711b331d66e33b3893 /FireBase/Http
parent3de6fb5d7bd28318d90975f016c9722a99ba2455 (diff)
parent373af0a9c563dcd6bfb5e136f75f23e48bfb961c (diff)
Merge branch 'WebApi' of https://github.com/TrueDoctor/DiscoBot into WebApi
Diffstat (limited to 'FireBase/Http')
-rw-r--r--FireBase/Http/HttpClientExtensions.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/FireBase/Http/HttpClientExtensions.cs b/FireBase/Http/HttpClientExtensions.cs
index 444145b..5d15c59 100644
--- a/FireBase/Http/HttpClientExtensions.cs
+++ b/FireBase/Http/HttpClientExtensions.cs
@@ -52,6 +52,46 @@ namespace Firebase.Database.Http
}
}
+ /*/// <summary>
+ /// The get object collection async.
+ /// </summary>
+ /// <param name="client"> The client. </param>
+ /// <param name="requestUri"> The request uri. </param>
+ /// /// <param name="dataType"> The Data Type. </param>
+ /// <param name="jsonSerializerSettings"> The specific JSON Serializer Settings. </param>
+ /// <typeparam name="T"> The type of entities the collection should contain. </typeparam>
+ /// <returns> The <see cref="Task"/>. </returns>
+ public static async Task<IReadOnlyCollection<FirebaseObject<object>>> GetObjectCollectionAsync(this HttpClient client, string requestUri,
+ JsonSerializerSettings jsonSerializerSettings, Type dataType)
+ {
+ var responseData = string.Empty;
+ var statusCode = HttpStatusCode.OK;
+
+ try
+ {
+ var response = await client.GetAsync(requestUri).ConfigureAwait(false);
+ statusCode = response.StatusCode;
+ responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
+
+ response.EnsureSuccessStatusCode();
+
+ Type dicType = typeof(Dictionary<,>).MakeGenericType(typeof(string), dataType);
+
+ var dictionary = JsonConvert.DeserializeObject(responseData,dicType, jsonSerializerSettings) as Dictionary<string, object>;
+
+ if (dictionary == null)
+ {
+ return new FirebaseObject<object>[0];
+ }
+
+ return dictionary.Select(item => new FirebaseObject<object>(item.Key, item.Value)).ToList();
+ }
+ catch (Exception ex)
+ {
+ throw new FirebaseException(requestUri, string.Empty, responseData, statusCode, ex);
+ }
+ }*/
+
/// <summary>
/// The get object collection async.
/// </summary>