public async Task <string> StoreImages(Stream imageStream) { return(await new FirebaseStorage("xamarinfirst-440bf.appspot.com") .Child("FirstImage/" + FirebaseKeyGenerator.Next()) .PutAsync(imageStream));// Burada sadece fotograf upload islemi yapilmistir. //Istenirse kullanci kayit olurken kullanicinin unique key alinip o unique key ile resim upload edilebilir }
public IObservable <Unit> Upsert(IEnumerable <T> items) { // Doesn't work offline. Need offline solution. return(_baseQuery .PatchAsync(items.ToDictionary(x => x.Id = x.Id ?? FirebaseKeyGenerator.Next())) .ToObservable() .SelectMany(_ => _realtimeDb.PullAsync().ToObservable())); }
/// <summary> /// Adds a new entity to the Database. /// </summary> /// <param name="obj"> The object to add. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> /// <returns> The generated key for this object. </returns> public string Post(T obj, bool syncOnline = true, int priority = 1) { var key = FirebaseKeyGenerator.Next(); this.SetAndRaise(key, new OfflineEntry(key, obj, priority, syncOnline ? SyncOptions.Push : SyncOptions.None)); return(key); }
/// <summary> /// Adds a new entity to the database. /// </summary> /// <param name="obj"> The object to add. </param> /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> /// <returns> The generated key for this object. </returns> public string Post(T obj, int priority = 1) { var key = FirebaseKeyGenerator.Next(); this.SetAndRaise(key, new OfflineEntry(key, obj, priority)); return(key); }
/// <summary> /// Adds a new entity to the Database. /// </summary> /// <param name="obj"> The object to add. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> /// <returns> The generated key for this object. </returns> public static string Post <T>(this RealtimeDatabase <T> db, T obj, bool syncOnline = true, int priority = 1) where T : class { var key = FirebaseKeyGenerator.Next(); db.Set(key, obj, syncOnline ? SyncOptions.Put : SyncOptions.None, priority); return(key); }
/// <summary> /// Post a new entity into the nested dictionary specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. /// The key of the new entity is automatically generated. /// </summary> /// <typeparam name="T"> Type of the root elements. </typeparam> /// <typeparam name="TSelector"> Type of the dictionary being modified</typeparam> /// <typeparam name="TProperty"> Type of the value within the dictionary being modified</typeparam> /// <param name="db"> Database instance. </param> /// <param name="key"> Key of the root element to modify. </param> /// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param> /// <param name="value"> Value to put. </param> /// <param name="syncOnline"> Indicates whether the item should be synced online. </param> /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param> public static void Post <T, TSelector, TProperty>(this RealtimeDatabase <T> db, string key, Expression <Func <T, TSelector> > propertyExpression, TProperty value, bool syncOnline = true, int priority = 1) where T : class where TSelector : IDictionary <string, TProperty> { var nextKey = FirebaseKeyGenerator.Next(); var expression = Expression.Lambda <Func <T, TProperty> >(Expression.Call(propertyExpression.Body, typeof(TSelector).GetRuntimeMethod("get_Item", new[] { typeof(string) }), Expression.Constant(nextKey)), propertyExpression.Parameters); db.Set(key, expression, value, syncOnline ? SyncOptions.Put : SyncOptions.None, priority); }
public string AddTask(long chatId, int level, Exercise exercise) { var key = FirebaseKeyGenerator.Next(); Database .Child("history") .Child(chatId.ToString) .Child(key) .PutAsync(new InfoModel(level)); Database .Child("tasks") .Child(key) .PutAsync(new ExerciseModel( exercise.GetComplexity().ToString(), exercise.ToString())); return(key); }
/// <summary> /// Posts given object to repository. /// </summary> /// <param name="obj"> The object. </param> /// <param name="generateKeyOffline"> Specifies whether the key should be generated offline instead of online. </param> /// <typeparam name="T"> Type of <see cref="obj"/> </typeparam> /// <returns> Resulting firebase object with populated key. </returns> public async Task <FirebaseObject <string> > PostAsync(string data, bool generateKeyOffline = true) { // post generates a new key server-side, while put can be used with an already generated local key if (generateKeyOffline) { var key = FirebaseKeyGenerator.Next(); await new ChildQuery(this, () => key, this.Client).PutAsync(data).ConfigureAwait(false); return(new FirebaseObject <string>(key, data)); } else { var c = this.GetClient(); var sendData = await this.SendAsync(c, data, HttpMethod.Post).ConfigureAwait(false); var result = JsonConvert.DeserializeObject <PostResult>(sendData, Client.Options.JsonSerializerSettings); return(new FirebaseObject <string>(result.Name, data)); } }
/// <summary> /// Posts given object to repository. /// </summary> /// <param name="obj"> The object. </param> /// <param name="generateKeyOffline"> Specifies whether the key should be generated offline instead of online. </param> /// <typeparam name="T"> Type of <see cref="obj"/> </typeparam> /// <returns> Resulting firebase object with populated key. </returns> public async Task <FirebaseObject <T> > PostAsync <T>(T obj, bool generateKeyOffline = true) { // post generates a new key server-side, while put can be used with an already generated local key if (generateKeyOffline) { var key = FirebaseKeyGenerator.Next(); await new ChildQuery(this, () => key, this.Client).PutAsync(obj).ConfigureAwait(false); return(new FirebaseObject <T>(key, obj)); } else { var c = this.GetClient(); var data = await this.SendAsync(c, obj, HttpMethod.Post).ConfigureAwait(false); var result = JsonConvert.DeserializeObject <PostResult>(data); return(new FirebaseObject <T>(result.Name, obj)); } }
public async Task <bool> saveUser(Student student) { try { await client.Child("Student/" + FirebaseKeyGenerator.Next()) .WithAuth(UserLocalData.userToken) .PutAsync(student); return(true); } catch (Exception ex) { if (ex.Message == "401 (Unauthorized)") { await authUser(); return(await saveUser(student)); } Debug.WriteLine("bir hatayla karşılaşıldı {0}", ex); return(false); } }
/// <inheritdoc/> public IObservable <Unit> Add(IEnumerable <T> items) { return(_childQuery .PatchAsync(items.ToDictionary(_ => FirebaseKeyGenerator.Next())) .ToObservable()); }
public void TestKeyGenerator() { // var key = new FirebaseKeyGenerator(); var keygenerated = FirebaseKeyGenerator.Next(); }