CloneRequest ShowCloneDialog(IGitHubServiceProvider gitHubServiceProvider, IGitRepositoriesExt gitRepositories, IRepositoryModel repository = null) { string basePath = null; gitHubServiceProvider.AddService(this, gitRepositories); var uiProvider = gitHubServiceProvider.GetService <IUIProvider>(); var controller = uiProvider.Configure(repository == null ? UIControllerFlow.Clone : UIControllerFlow.StartPageClone, null //TODO: set the connection corresponding to the repository if the repository is not null ); controller.TransitionSignal.Subscribe(x => { if ((repository == null && x.Data.ViewType == Exports.UIViewType.Clone) || // fire the normal clone dialog (repository != null && x.Data.ViewType == Exports.UIViewType.StartPageClone) // fire the clone dialog for re-acquiring a repo ) { var vm = x.View.ViewModel as IBaseCloneViewModel; if (repository != null) { vm.SelectedRepository = repository; } x.View.Done.Subscribe(_ => { basePath = vm.BaseRepositoryPath; if (repository == null) { repository = vm.SelectedRepository; } }); } }); uiProvider.RunInDialog(controller); gitHubServiceProvider.RemoveService(typeof(IGitRepositoriesExt), this); return(repository != null && basePath != null ? new CloneRequest(basePath, repository) : null); }
public void Start() { if (connection != null) { if (selectedFlow != UIControllerFlow.Authentication) { gitHubServiceProvider.AddService(this, connection); } else // sanity check: it makes zero sense to pass a connection in when calling the auth flow { Log.Assert(false, "Calling the auth flow with a connection makes no sense!"); } connectionManager.GetLoadedConnections().ToObservable() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { }, () => { Debug.WriteLine("Start ({0})", GetHashCode()); Fire(Trigger.Next); }); } else { connectionManager .GetLoggedInConnections() .FirstOrDefaultAsync() .Select(c => { bool loggedin = c != null; if (selectedFlow != UIControllerFlow.Authentication) { if (loggedin) // register the first available connection so the viewmodel can use it { connection = c; gitHubServiceProvider.AddService(this, c); } else { // a connection will be added to the list when auth is done, register it so the next // viewmodel can use it connectionAdded = (s, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { connection = e.NewItems[0] as IConnection; if (connection != null) { gitHubServiceProvider.AddService(typeof(IConnection), this, connection); } } }; connectionManager.Connections.CollectionChanged += connectionAdded; } } return(loggedin); }) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { }, () => { Debug.WriteLine("Start ({0})", GetHashCode()); Fire(Trigger.Next); }); } }
public void AddService(Type t, object owner, object instance) => theRealProvider.AddService(t, owner, instance);