summaryrefslogtreecommitdiff
path: root/FireBase
diff options
context:
space:
mode:
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.