public string Push<T>(T data, FirebasePromise<bool> onCompletion = null)
 {
     var newNode = databaseReference.Push();
     var command = newNode.SetValue(ToNativeConverter.ToNative(data.GetType(), data));
     if (onCompletion != null)
         command.AddOnCompleteListener(new CommandCompletedListener(onCompletion));
     return newNode.Key;
 }
        public void Update<T>(T data, FirebasePromise<bool> onCompletion = null)
        {
            var newNode = databaseReference;
            var convertedData = ToNativeConverter.ToDictionary(typeof(T), data);

            newNode.UpdateChildren(convertedData).AddOnCompleteListener(new CommandCompletedListener(onCompletion));

        }
 public string Put<T>(T data, FirebasePromise<bool> onCompletion = null)
 {
     var newNode = databaseReference;
     var convertedData = ToNativeConverter.ToNative(typeof(T), data);
     var command = newNode.SetValue(convertedData);
     if (onCompletion != null)
         command.AddOnCompleteListener(new CommandCompletedListener(onCompletion));
     return newNode.Key;
 }
 public void Update <T>(T data, FirebasePromise <bool> onCompletion = null)
 {
     databaseReference.UpdateChildValues(DataConverter.ToDictionary(data), (error, reference) =>
     {
         if (onCompletion != null)
         {
             onCompletion.OnComplete(error == null);
             if (error != null)
             {
                 onCompletion.OnError(new FirebaseException(error));
             }
         }
     });
 }
        public void PutData(string path, Stream stream, FirebasePromise <FirebaseFileResult> onCompleted)
        {
            var uploadReference = storage.GetRootReference().GetChild(path);

            uploadReference.PutData(NSData.FromStream(stream), null, async(metadata, error) =>
            {
                var downloadUrl = await uploadReference.GetDownloadUrlAsync();
                onCompleted?.OnComplete(new FirebaseFileResult()
                {
                    IsSuccess   = error == null,
                    DownloadUrl = downloadUrl.AbsoluteString
                });
            });
        }
        public void Remove(FirebasePromise <bool> onCompletion = null)
        {
            var rootNode = databaseReference;

            rootNode.RemoveValue((error, reference) =>
            {
                if (onCompletion != null)
                {
                    onCompletion.OnComplete(error == null);
                    if (error != null)
                    {
                        onCompletion.OnError(new FirebaseException(error));
                    }
                }
            });
        }
        public string Put <T>(T data, FirebasePromise <bool> onCompletion = null)
        {
            var nativeData = DataConverter.ToNative(data);

            databaseReference.SetValue(nativeData, (error, reference) =>
            {
                if (onCompletion != null)
                {
                    onCompletion.OnComplete(error == null);
                    if (error != null)
                    {
                        onCompletion.OnError(new FirebaseException(error));
                    }
                }
            });
            return(databaseReference.Key);
        }
        public string Push <T>(T data, FirebasePromise <bool> onCompletion = null)
        {
            var rootNode = databaseReference;

            rootNode = rootNode.GetChildByAutoId();
            rootNode.SetValue(DataConverter.ToNative(data), (error, reference) =>
            {
                if (onCompletion != null)
                {
                    onCompletion.OnComplete(error == null);
                    if (error != null)
                    {
                        onCompletion.OnError(new FirebaseException(error));
                    }
                }
            });
            return(rootNode.Key);
        }
        public void PutFile(string path, string uri, FirebasePromise <FirebaseFileResult> onCompleted)
        {
            var uploadReference = storage.GetRootReference().GetChild(path);

            uploadReference.PutFile(NSUrl.FromFilename(uri), null, async(metadata, error) =>
            {
                try
                {
                    var downloadUrl = await uploadReference.GetDownloadUrlAsync();
                    onCompleted?.OnComplete(new FirebaseFileResult()
                    {
                        IsSuccess   = error == null,
                        DownloadUrl = downloadUrl.AbsoluteString
                    });
                }
                catch (Exception ex)
                {
                    onCompleted?.OnError(new FirebaseException(ex));
                }
            });
        }
        public void Transaction <T>(Action <FirebaseMutableData <T> > transaction, FirebasePromise <bool> onCompletion = null)
        {
            var rootNode = databaseReference;

            rootNode.RunTransaction((currentData) =>
            {
                if (transaction != null)
                {
                    transaction.Invoke(new IosMutableData <T>(currentData));
                }
                return(TransactionResult.Success(currentData));
            }, (error, commited, snapshot) =>
            {
                if (onCompletion != null)
                {
                    onCompletion.OnComplete(commited);
                    if (error != null)
                    {
                        onCompletion.OnError(new FirebaseException(error));
                    }
                }
            });
        }
Пример #11
0
        public void PutFile(string path, string uri, FirebasePromise <FirebaseFileResult> onCompleted)
        {
            var reference = storage.GetReference(path);

            reference.PutFile(Android.Net.Uri.FromFile(new Java.IO.File(uri))).AddOnCompleteListener(new FileCompletedListener(reference, onCompleted));
        }
 public void Transaction<T>(Action<FirebaseMutableData<T>> transaction, FirebasePromise<bool> onCompletion = null)
 {
     databaseReference.RunTransaction(new FuncTransactionHandler<T>(transaction, onCompletion));
 }
 public FuncTransactionHandler(Action <FirebaseMutableData <T> > transaction, FirebasePromise <bool> onCompletion = null)
 {
     this.transaction  = transaction;
     this.onCompletion = onCompletion;
 }
Пример #14
0
 public FileCompletedListener(StorageReference storageReference, FirebasePromise <FirebaseFileResult> onCompleted)
 {
     this.downloadListener = new DownloadUrlCompletedListener(storageReference, onCompleted);
     this.storageReference = storageReference;
 }
Пример #15
0
 public void Remove(string path, FirebasePromise <bool> onCompletion = null)
 {
     GetChild(path).Remove(onCompletion);
 }
Пример #16
0
 public void Transaction <T>(string path, Action <FirebaseMutableData <T> > transaction, FirebasePromise <bool> onCompletion = null)
 {
     GetChild(path).Transaction(transaction, onCompletion);
 }
Пример #17
0
 public string Put <T>(string path, T data, FirebasePromise <bool> onCompletion = null)
 {
     return(GetChild(path).Put(data, onCompletion));
 }
 public void Remove(FirebasePromise<bool> onCompletion = null)
 {
     var command = databaseReference.RemoveValue();
     if (onCompletion != null)
         command.AddOnCompleteListener(new CommandCompletedListener(onCompletion));
 }
Пример #19
0
        public void PutData(string path, Stream stream, FirebasePromise <FirebaseFileResult> onCompleted)
        {
            var reference = storage.GetReference(path);

            reference.PutStream(stream).AddOnCompleteListener(new FileCompletedListener(reference, onCompleted));
        }
 public LoginCompletedListener(FirebasePromise <bool> completedListener)
 {
     this.completedListener = completedListener;
 }
Пример #21
0
 public DownloadUrlCompletedListener(StorageReference storageReference, FirebasePromise <FirebaseFileResult> onCompleted)
 {
     this.storageReference = storageReference;
     this.onCompleted      = onCompleted;
 }
 public CommandCompletedListener(FirebasePromise <bool> completedListener)
 {
     this.completedListener = completedListener;
 }