private IObservable <Unit> ToggleProxy( IProxyManager proxyManager, bool isEnabled) { if (isEnabled) { if (Model.SelectedProxy != null) { return(proxyManager.DisableProxy() .Concat(proxyManager.EnableProxy(Model.SelectedProxy.Proxy))); } } else { proxyManager.DisableProxy(); } return(Observable.Empty <Unit>()); }
private void ToggleProxy(IProxyManager proxyManager, bool isEnabled) { if (isEnabled) { if (SelectedProxy != null) { proxyManager.DisableProxy() .Concat(proxyManager.EnableProxy(SelectedProxy.Proxy)) .Subscribe() .DisposeWith(_modelDisposable); } } else { proxyManager.DisableProxy() .Subscribe() .DisposeWith(_modelDisposable); } }
private static IObservable <ProxyModel> EnableProxy( this ProxyPopupContext context, IProxyManager proxyManager, ProxyModel proxyModel) { if (!proxyModel.IsEnabled) { if (proxyModel.Proxy != null) { return(proxyManager .EnableProxy(proxyModel.Proxy) .Select(_ => proxyModel)); } return(proxyManager .DisableProxy() .Select(_ => proxyModel)); } return(Observable.Return(proxyModel)); }