Exemplo 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);
        }
Exemplo 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);
     }
 }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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);
            }
        }
Exemplo 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();
                }
            }
        }
Exemplo 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);
            }
        }
Exemplo 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));
        }
Exemplo n.º 9
0
 internal _EventSinkWrapper(_EventSink <T> _sink)
 {
     this._sink = _sink;
 }
Exemplo n.º 10
0
 internal virtual void _handleDone(_EventSink <T> sink)
 {
     sink._close();
 }
Exemplo n.º 11
0
        internal virtual void _handleError(object error, _EventSink <T> sink)
        {
            string stackTrace = error is Exception ? ((Exception)error).StackTrace : "";

            sink._addError(error, stackTrace);
        }
Exemplo 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);
        }