コード例 #1
0
        public IListenerRegistration AddSnapshotListener(bool includeMetadataChanges, DocumentSnapshotHandler listener)
        {
            var registration = _documentReference.AddSnapshotListener(includeMetadataChanges ? MetadataChanges.Include : MetadataChanges.Exclude, new EventHandlerListener <DocumentSnapshot>((value, error) =>
            {
                listener?.Invoke(value == null ? null : new DocumentSnapshotWrapper(value),
                                 error == null ? null : ExceptionMapper.Map(error));
            }));

            return(new ListenerRegistrationWrapper(registration));
        }
コード例 #2
0
        public IListenerRegistration AddSnapshotListener(DocumentSnapshotHandler listener)
        {
            var registration = _documentReference.AddSnapshotListener(new EventHandlerListener <DocumentSnapshot>((value, error) =>
            {
                listener?.Invoke(value == null ? null : new DocumentSnapshotWrapper(value),
                                 error == null ? null : ExceptionMapper.Map(error));
            }));

            return(new ListenerRegistrationWrapper(registration));
        }
コード例 #3
0
        public void GetDocument(DocumentSnapshotHandler handler)
        {
            var tcs = new TaskCompletionSource <IDocumentSnapshot>();

            DocumentReference.Get().AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
            {
                var snapshot = !task.IsSuccessful ? null : task.Result.JavaCast <DocumentSnapshot>();
                handler?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot),
                                task.IsSuccessful ? null : new CloudFirestoreException(task.Exception.Message));
            }));
        }
コード例 #4
0
        public void GetDocument(Source source, DocumentSnapshotHandler handler)
        {
            var tcs = new TaskCompletionSource <IDocumentSnapshot>();

            _documentReference.Get(source.ToNative()).AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
            {
                var snapshot = !task.IsSuccessful ? null : task.Result.JavaCast <DocumentSnapshot>();
                handler?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot),
                                task.IsSuccessful ? null : ExceptionMapper.Map(task.Exception));
            }));
        }
コード例 #5
0
        public IListenerRegistration AddSnapshotListener(bool includeMetadataChanges, DocumentSnapshotHandler listener)
        {
            if (!includeMetadataChanges)
            {
                return(AddSnapshotListener(listener));
            }

            var option = new DocumentListenOptions().IncludeMetadataChanges();

            var registration = DocumentReference.AddSnapshotListener(option, new EventHandlerListener <DocumentSnapshot>((value, error) =>
            {
                listener?.Invoke(value == null ? null : new DocumentSnapshotWrapper(value),
                                 error == null ? null : new CloudFirestoreException(error.Message));
            }));

            return(new ListenerRegistrationWrapper(registration));
        }