diff options
author | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-09-29 17:19:43 +0200 |
---|---|---|
committer | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-09-29 17:19:43 +0200 |
commit | b83fc90abacc73262e0f8404cebadf6d64eb10ae (patch) | |
tree | d63b921c9bcdf8d381fc02ecfb0a1dd425ebb561 /FireBase/FirebaseClient.cs | |
parent | 586d564f3c4c509c1aae931331e96f0382178f80 (diff) | |
parent | 680967aee589e4a8d277044b204de07cbe32f41e (diff) |
Merge branch 'WebApi' of https://github.com/TrueDoctor/DiscoBot into WebApi
Merged the stuffs
Diffstat (limited to 'FireBase/FirebaseClient.cs')
-rw-r--r-- | FireBase/FirebaseClient.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/FireBase/FirebaseClient.cs b/FireBase/FirebaseClient.cs new file mode 100644 index 0000000..a237c8d --- /dev/null +++ b/FireBase/FirebaseClient.cs @@ -0,0 +1,57 @@ +using System.Net.Http; + +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Firebase.Database.Tests")] + +namespace Firebase.Database +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + + using Firebase.Database.Offline; + using Firebase.Database.Query; + + /// <summary> + /// Firebase client which acts as an entry point to the online database. + /// </summary> + public class FirebaseClient : IDisposable + { + internal readonly HttpClient HttpClient; + internal readonly FirebaseOptions Options; + + private readonly string baseUrl; + + /// <summary> + /// Initializes a new instance of the <see cref="FirebaseClient"/> class. + /// </summary> + /// <param name="baseUrl"> The base url. </param> + /// <param name="offlineDatabaseFactory"> Offline database. </param> + public FirebaseClient(string baseUrl, FirebaseOptions options = null) + { + this.HttpClient = new HttpClient(); + this.Options = options ?? new FirebaseOptions(); + + this.baseUrl = baseUrl; + + if (!this.baseUrl.EndsWith("/")) + { + this.baseUrl += "/"; + } + } + + /// <summary> + /// Queries for a child of the data root. + /// </summary> + /// <param name="resourceName"> Name of the child. </param> + /// <returns> <see cref="ChildQuery"/>. </returns> + public ChildQuery Child(string resourceName) + { + return new ChildQuery(this, () => this.baseUrl + resourceName); + } + + public void Dispose() + { + HttpClient?.Dispose(); + } + } +} |