示例#1
0
            public IDisposable Run(Using <TSource, TResource> parent)
            {
                var source     = default(IObservable <TSource>);
                var disposable = Disposable.Empty;

                try
                {
                    var resource = parent._resourceFactory();
                    if (resource != null)
                    {
                        disposable = resource;
                    }
                    source = parent._observableFactory(resource);
                }
                catch (Exception exception)
                {
                    return(StableCompositeDisposable.Create(Observable.Throw <TSource>(exception).SubscribeSafe(this), disposable));
                }

                return(StableCompositeDisposable.Create(source.SubscribeSafe(this), disposable));
            }
示例#2
0
文件: Using.cs 项目: shekky/reactive
            public void Run(Using <TSource, TResource> parent)
            {
                var source = default(IObservable <TSource>);

                try
                {
                    var resource = parent._resourceFactory();
                    if (resource != null)
                    {
                        Disposable.SetSingle(ref _disposable, resource);
                    }
                    source = parent._observableFactory(resource);
                }
                catch (Exception exception)
                {
                    SetUpstream(Observable.Throw <TSource>(exception).SubscribeSafe(this));

                    return;
                }

                base.Run(source);
            }
示例#3
0
 public _(Using <TSource, TResource> parent, IObserver <TSource> observer, IDisposable cancel)
     : base(observer, cancel)
 {
     _parent = parent;
 }