Esempio n. 1
0
//
        internal static void _addErrorWithReplacement <T>(_EventSink <T> sink, Exception error, string stackTrace)
        {
            AsyncError replacement = Zone.current.errorCallback(error);

            if (replacement != null)
            {
                error      = async_._nonNullError(replacement);
                stackTrace = replacement.StackTrace;
            }

            sink._addError(error, stackTrace);
        }
Esempio n. 2
0
 internal override void _handleData(S inputEvent, _EventSink <T> sink)
 {
     try {
         foreach (T value in _expand(inputEvent))
         {
             sink._add(value);
         }
     }
     catch (Exception e) {
         // If either _expand or iterating the generated iterator throws,
         // we abort the iteration.
         _stream._addErrorWithReplacement(sink, e, e.StackTrace);
     }
 }
Esempio n. 3
0
        internal override void _handleData(S inputEvent, _EventSink <T> sink)
        {
            T outputEvent;

            try {
                outputEvent = _transform(inputEvent);
            }
            catch (Exception e) {
                _stream._addErrorWithReplacement(sink, e, e.StackTrace);
                return;
            }

            sink._add(outputEvent);
        }
Esempio n. 4
0
        public WebBrowserEvents(WebBrowser browser)
        {
            if (browser.Document == null)
            {
                throw new InvalidOperationException("Can't add an event sink until the browser's document is non-null");
            }

            var serviceProvider = (IServiceProvider)browser.Document;
            var serviceGuid     = new Guid(SID.SWebBrowserApp);
            var iid             = new Guid(IID.ConnectionPointContainer);
            var cpc             = (IConnectionPointContainer)serviceProvider.QueryService(ref serviceGuid, ref iid);

            _sink   = new _EventSink(this);
            _cookie = new SafeConnectionPointCookie(cpc, _sink, new Guid(IID.WebBrowserEvents2));
        }
Esempio n. 5
0
        internal override void _handleData(T inputEvent, _EventSink <T> sink)
        {
            bool satisfies;

            try {
                satisfies = _test(inputEvent);
            }
            catch (Exception e) {
                _stream._addErrorWithReplacement(sink, e, e.StackTrace);
                return;
            }

            if (satisfies)
            {
                sink._add(inputEvent);
            }
        }
Esempio n. 6
0
        internal override void _handleData(T inputEvent, _EventSink <T> sink)
        {
            _StateStreamSubscription <T> subscription = (_StateStreamSubscription <T>)sink;
            int count = subscription._count;

            if (count > 0)
            {
                sink._add(inputEvent);
                count -= 1;
                subscription._count = count;
                if (count == 0)
                {
                    // Closing also unsubscribes all subscribers, which unsubscribes
                    // this from source.
                    sink._close();
                }
            }
        }
Esempio n. 7
0
        internal override void _handleError(object error, _EventSink <T> sink)
        {
            bool matches = true;

            if (_test != null)
            {
                try {
                    matches = _test((Exception)error);
                }
                catch (Exception e) {
                    _stream._addErrorWithReplacement(sink, e, e.StackTrace);
                    return;
                }
            }

            string stackTrace = error is Exception ? ((Exception)error).StackTrace : "";

            if (matches)
            {
                try {
                    _async._invokeErrorHandler(_transform, error, stackTrace);
                }
                catch (Exception e) {
                    if (Equals(e, error))
                    {
                        sink._addError(error, stackTrace);
                    }
                    else
                    {
                        _stream._addErrorWithReplacement(sink, e, e.StackTrace);
                    }

                    return;
                }
            }
            else
            {
                sink._addError(error, stackTrace);
            }
        }
Esempio n. 8
0
        public WebBrowserEvents(WebBrowser browser)
        {
            if (browser.Document == null)
            {
                throw new InvalidOperationException("Can't add an event sink until the browser's document is non-null");
            }

            var serviceProvider = (IServiceProvider)browser.Document;
            var serviceGuid = new Guid(SID.SWebBrowserApp);
            var iid = new Guid(IID.ConnectionPointContainer);
            var cpc = (IConnectionPointContainer)serviceProvider.QueryService(ref serviceGuid, ref iid);

            _sink = new _EventSink(this);
            _cookie = new SafeConnectionPointCookie(cpc, _sink, new Guid(IID.WebBrowserEvents2));
        }
Esempio n. 9
0
 internal _EventSinkWrapper(_EventSink <T> _sink)
 {
     this._sink = _sink;
 }
Esempio n. 10
0
 internal virtual void _handleDone(_EventSink <T> sink)
 {
     sink._close();
 }
Esempio n. 11
0
        internal virtual void _handleError(object error, _EventSink <T> sink)
        {
            string stackTrace = error is Exception ? ((Exception)error).StackTrace : "";

            sink._addError(error, stackTrace);
        }
Esempio n. 12
0
        // Override the following methods in subclasses to change the behavior.

        internal virtual void _handleData(S data, _EventSink <T> sink)
        {
            sink._add((T)(object)data);
        }