public PullRequestSessionManager( IPullRequestService service, IPullRequestSessionService sessionService, IConnectionManager connectionManager, IModelServiceFactory modelServiceFactory, ITeamExplorerContext teamExplorerContext) { Guard.ArgumentNotNull(service, nameof(service)); Guard.ArgumentNotNull(sessionService, nameof(sessionService)); Guard.ArgumentNotNull(connectionManager, nameof(connectionManager)); Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext)); this.service = service; this.sessionService = sessionService; this.connectionManager = connectionManager; this.modelServiceFactory = modelServiceFactory; initialized = new TaskCompletionSource <object>(null); Observable.FromEventPattern(teamExplorerContext, nameof(teamExplorerContext.StatusChanged)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => StatusChanged().Forget()); teamExplorerContext.WhenAnyValue(x => x.ActiveRepository) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => RepoChanged(x).Forget()); }
async Task CreateInitializeTask(IServiceProvider paneServiceProvider) { await UpdateContent(teamExplorerContext.ActiveRepository); teamExplorerContext.WhenAnyValue(x => x.ActiveRepository) .Skip(1) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => UpdateContent(x).Forget(log)); connectionManager.Connections.CollectionChanged += (_, __) => UpdateContent(LocalRepository).Forget(log); var menuService = (IMenuCommandService)paneServiceProvider.GetService(typeof(IMenuCommandService)); BindNavigatorCommand(menuService, PkgCmdIDList.pullRequestCommand, showPullRequests); BindNavigatorCommand(menuService, PkgCmdIDList.backCommand, navigator.NavigateBack); BindNavigatorCommand(menuService, PkgCmdIDList.forwardCommand, navigator.NavigateForward); BindNavigatorCommand(menuService, PkgCmdIDList.refreshCommand, refresh); BindNavigatorCommand(menuService, PkgCmdIDList.githubCommand, openInBrowser); BindNavigatorCommand(menuService, PkgCmdIDList.helpCommand, help); }
/// <inheritdoc/> public async Task InitializeAsync(IServiceProvider paneServiceProvider) { await initializing.WaitAsync(); if (initialized) { return; } try { await UpdateContent(teamExplorerContext.ActiveRepository); teamExplorerContext.WhenAnyValue(x => x.ActiveRepository) .Skip(1) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => UpdateContent(x).Forget()); connectionManager.Connections.CollectionChanged += (_, __) => UpdateContent(LocalRepository).Forget(); BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.pullRequestCommand, showPullRequests); BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.backCommand, navigator.NavigateBack); BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.forwardCommand, navigator.NavigateForward); BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.refreshCommand, refresh); BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.githubCommand, openInBrowser); paneServiceProvider.AddCommandHandler(Guids.guidGitHubToolbarCmdSet, PkgCmdIDList.helpCommand, (_, __) => { browser.OpenUrl(new Uri(GitHubUrls.Documentation)); usageTracker.IncrementCounter(x => x.NumberOfGitHubPaneHelpClicks).Forget(); }); } finally { initialized = true; initializing.Release(); } }