summaryrefslogtreecommitdiff
path: root/FireBase
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-10-01 22:20:36 +0200
committerTrueDoctor <d-kobert@web.de>2018-10-01 22:20:36 +0200
commitb7ef3c860375baea7b5db95940519ce0746b6ecc (patch)
tree270b9f6ec1c58b153037738f6c6b2aa83205d9fc /FireBase
parenta5a5d368cddd6e8a15298002ccb3b10c90a33980 (diff)
added Command Response Handling
Diffstat (limited to 'FireBase')
-rw-r--r--FireBase/Http/HttpClientExtensions.cs40
-rw-r--r--FireBase/Query/FirebaseQuery.cs16
2 files changed, 56 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>
diff --git a/FireBase/Query/FirebaseQuery.cs b/FireBase/Query/FirebaseQuery.cs
index 0e1b84a..3513c85 100644
--- a/FireBase/Query/FirebaseQuery.cs
+++ b/FireBase/Query/FirebaseQuery.cs
@@ -66,6 +66,22 @@ namespace Firebase.Database.Query
.ConfigureAwait(false);
}
+ /*public async Task<IReadOnlyCollection<FirebaseObject<Object>>> OnceAsync(Type dataType, TimeSpan? timeout = null)
+ {
+ var url = string.Empty;
+
+ try
+ {
+ url = await this.BuildUrlAsync().ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ throw new FirebaseException("Couldn't build the url", string.Empty, string.Empty, HttpStatusCode.OK, ex);
+ }
+
+ return await this.GetClient(timeout).GetObjectCollectionAsync(url, Client.Options.JsonSerializerSettings, dataType)
+ .ConfigureAwait(false);
+ }*/
/// <summary>
/// Assumes given query is pointing to a single object of type <typeparamref name="T"/> and retrieves it.