From de0f076ef9ff546c9a90513259ad6c42cd2224b3 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Sat, 29 Sep 2018 16:51:26 +0200 Subject: added firebase api --- FireBase/FirebaseClient.cs | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 FireBase/FirebaseClient.cs (limited to 'FireBase/FirebaseClient.cs') 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; + + /// + /// Firebase client which acts as an entry point to the online database. + /// + public class FirebaseClient : IDisposable + { + internal readonly HttpClient HttpClient; + internal readonly FirebaseOptions Options; + + private readonly string baseUrl; + + /// + /// Initializes a new instance of the class. + /// + /// The base url. + /// Offline database. + 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 += "/"; + } + } + + /// + /// Queries for a child of the data root. + /// + /// Name of the child. + /// . + public ChildQuery Child(string resourceName) + { + return new ChildQuery(this, () => this.baseUrl + resourceName); + } + + public void Dispose() + { + HttpClient?.Dispose(); + } + } +} -- cgit v1.2.3-70-g09d2