diff options
author | uzvkl <dennis.kobert@student.kit.edu> | 2019-06-11 23:05:52 +0200 |
---|---|---|
committer | uzvkl <dennis.kobert@student.kit.edu> | 2019-06-11 23:05:52 +0200 |
commit | e6181c24124d97f2fbc932b8a68311e625463156 (patch) | |
tree | c1f097c344ca266b7941c9668590b0fd35c7870a /dsa/FireBase/FirebaseClient.cs | |
parent | 2490ad5d31fe2ac778ff9303776f0e91f47a2862 (diff) |
Move dsa related stuff to subfolder
Diffstat (limited to 'dsa/FireBase/FirebaseClient.cs')
-rw-r--r-- | dsa/FireBase/FirebaseClient.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/dsa/FireBase/FirebaseClient.cs b/dsa/FireBase/FirebaseClient.cs new file mode 100644 index 0000000..3079f3b --- /dev/null +++ b/dsa/FireBase/FirebaseClient.cs @@ -0,0 +1,49 @@ +using System; +using System.Net.Http; +using System.Runtime.CompilerServices; +using Firebase.Database.Query; + +[assembly: InternalsVisibleTo("Firebase.Database.Tests")] + +namespace Firebase.Database +{ + /// <summary> + /// Firebase client which acts as an entry point to the online database. + /// </summary> + public class FirebaseClient : IDisposable + { + private readonly string baseUrl; + internal readonly HttpClient HttpClient; + internal readonly FirebaseOptions Options; + + /// <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) + { + HttpClient = new HttpClient(); + Options = options ?? new FirebaseOptions(); + + this.baseUrl = baseUrl; + + if (!this.baseUrl.EndsWith("/")) this.baseUrl += "/"; + } + + public void Dispose() + { + HttpClient?.Dispose(); + } + + /// <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, () => baseUrl + resourceName); + } + } +}
\ No newline at end of file |