public void GetDocument(DocumentSnapshotHandler handler)
 {
     DocumentReference.GetDocument((snapshot, error) =>
     {
         handler?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot),
                         error == null ? null : new CloudFirestoreException(error.LocalizedDescription));
     });
 }
Example #2
0
 public void GetDocument(Source source, DocumentSnapshotHandler handler)
 {
     _documentReference.GetDocument(source.ToNative(), (snapshot, error) =>
     {
         handler?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot),
                         error == null ? null : ExceptionMapper.Map(error));
     });
 }
Example #3
0
        public IListenerRegistration AddSnapshotListener(DocumentSnapshotHandler listener)
        {
            var registration = _documentReference.AddSnapshotListener((snapshot, error) =>
            {
                listener?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot),
                                 error == null ? null : ExceptionMapper.Map(error));
            });

            return(new ListenerRegistrationWrapper(registration));
        }
Example #4
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 : new CloudFirestoreException(error.Message));
            }));

            return(new ListenerRegistrationWrapper(registration));
        }
        public IListenerRegistration AddSnapshotListener(DocumentSnapshotHandler listener)
        {
            var registration = DocumentReference.AddSnapshotListener((snapshot, error) =>
            {
                listener?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot),
                                 error == null ? null : new CloudFirestoreException(error.LocalizedDescription));
            });

            return(new ListenerRegistrationWrapper(registration));
        }
Example #6
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));
            }));
        }
Example #7
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));
            }));
        }
Example #8
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));
        }
Example #9
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));
        }
Example #10
0
        public static void GetCalibrationData(string deviceModel, DocumentSnapshotHandler completion)
        {
            var docRef = db.GetCollection(Collections.CalibrationData).GetDocument(deviceModel);

            docRef.GetDocument(completion);
        }
        private static Color GetBackgroundColorFromPixel(IHTMLElement e)
        {
            IHTMLElement divElement = (e.document as IHTMLDocument2).createElement("div");
            divElement.id = Guid.NewGuid().ToString();
            divElement.style.padding = "10px 10px 10px 10px";
            divElement.style.width = "100px";
            divElement.style.height = "100px";
            (e as IHTMLDOMNode).appendChild((IHTMLDOMNode)divElement);
            string documentHtml = HTMLDocumentHelper.HTMLDocToString(e.document as IHTMLDocument2);
            (e as IHTMLDOMNode).removeChild((IHTMLDOMNode)divElement);

            HtmlScreenCaptureCore screenCapture = new HtmlScreenCaptureCore(documentHtml, 800);
            DocumentSnapshotHandler snapshotHandler = new DocumentSnapshotHandler(divElement.id);
            screenCapture.HtmlDocumentAvailable += new HtmlDocumentAvailableHandlerCore(snapshotHandler.HtmlDocumentAvailable);
            Bitmap docImage = screenCapture.CaptureHtml(3000);
            using (Graphics g = Graphics.FromImage(docImage))
            {
                Rectangle rect = snapshotHandler.rect;
                g.DrawRectangle(new Pen(Color.Blue, 1), rect);
            }
            using (FileStream fs = new FileStream(@"c:\temp\docImage.png", FileMode.Create))
            {
                docImage.Save(fs, ImageFormat.Png);
            }

            Color c = docImage.GetPixel(snapshotHandler.rect.X + 5, snapshotHandler.rect.Y + 5);
            return c;
        }