diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /FireBase/Http | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'FireBase/Http')
-rw-r--r-- | FireBase/Http/HttpClientExtensions.cs | 55 | ||||
-rw-r--r-- | FireBase/Http/PostResult.cs | 12 |
2 files changed, 28 insertions, 39 deletions
diff --git a/FireBase/Http/HttpClientExtensions.cs b/FireBase/Http/HttpClientExtensions.cs index 5d15c59..6582769 100644 --- a/FireBase/Http/HttpClientExtensions.cs +++ b/FireBase/Http/HttpClientExtensions.cs @@ -1,29 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using Newtonsoft.Json; + namespace Firebase.Database.Http { - using System; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net.Http; - using System.Threading.Tasks; - - using Newtonsoft.Json; - using System.Net; - /// <summary> - /// The http client extensions for object deserializations. + /// The http client extensions for object deserializations. /// </summary> internal static class HttpClientExtensions { /// <summary> - /// The get object collection async. + /// The get object collection async. /// </summary> /// <param name="client"> The client. </param> - /// <param name="requestUri"> The request uri. </param> - /// <param name="jsonSerializerSettings"> The specific JSON Serializer Settings. </param> + /// <param name="requestUri"> The request uri. </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<T>>> GetObjectCollectionAsync<T>(this HttpClient client, string requestUri, + /// <returns> The <see cref="Task" />. </returns> + public static async Task<IReadOnlyCollection<FirebaseObject<T>>> GetObjectCollectionAsync<T>( + this HttpClient client, string requestUri, JsonSerializerSettings jsonSerializerSettings) { var responseData = string.Empty; @@ -37,12 +37,10 @@ namespace Firebase.Database.Http response.EnsureSuccessStatusCode(); - var dictionary = JsonConvert.DeserializeObject<Dictionary<string, T>>(responseData, jsonSerializerSettings); + var dictionary = + JsonConvert.DeserializeObject<Dictionary<string, T>>(responseData, jsonSerializerSettings); - if (dictionary == null) - { - return new FirebaseObject<T>[0]; - } + if (dictionary == null) return new FirebaseObject<T>[0]; return dictionary.Select(item => new FirebaseObject<T>(item.Key, item.Value)).ToList(); } @@ -93,11 +91,11 @@ namespace Firebase.Database.Http }*/ /// <summary> - /// The get object collection async. + /// The get object collection async. /// </summary> /// <param name="data"> The json data. </param> /// <param name="elementType"> The type of entities the collection should contain. </param> - /// <returns> The <see cref="Task"/>. </returns> + /// <returns> The <see cref="Task" />. </returns> public static IEnumerable<FirebaseObject<object>> GetObjectCollection(this string data, Type elementType) { var dictionaryType = typeof(Dictionary<,>).MakeGenericType(typeof(string), elementType); @@ -116,15 +114,10 @@ namespace Firebase.Database.Http dictionary = JsonConvert.DeserializeObject(data, dictionaryType) as IDictionary; } - if (dictionary == null) - { - yield break; - } + if (dictionary == null) yield break; foreach (DictionaryEntry item in dictionary) - { - yield return new FirebaseObject<object>((string)item.Key, item.Value); - } + yield return new FirebaseObject<object>((string) item.Key, item.Value); } } -} +}
\ No newline at end of file diff --git a/FireBase/Http/PostResult.cs b/FireBase/Http/PostResult.cs index 3f010d4..15a4894 100644 --- a/FireBase/Http/PostResult.cs +++ b/FireBase/Http/PostResult.cs @@ -1,17 +1,13 @@ namespace Firebase.Database.Http { /// <summary> - /// Represents data returned after a successful POST to firebase server. + /// Represents data returned after a successful POST to firebase server. /// </summary> public class PostResult { /// <summary> - /// Gets or sets the generated key after a successful post. + /// Gets or sets the generated key after a successful post. /// </summary> - public string Name - { - get; - set; - } + public string Name { get; set; } } -} +}
\ No newline at end of file |