예제 #1
0
        CompositionContainer CreateCompositionContainer()
        {
            var compositionServices = new CompositionServices();
            var exportProvider      = compositionServices.GetExportProvider();

            var compositionContainer      = new CompositionContainer(exportProvider);
            var gitHubServiceProvider     = exportProvider.GetExportedValue <IGitHubServiceProvider>();
            var externalShowDialogService = new ExternalShowDialogService(gitHubServiceProvider, this);

            compositionContainer.ComposeExportedValue <IShowDialogService>(externalShowDialogService);

            return(compositionContainer);
        }
예제 #2
0
        async Task ShowPublishDialogAsync()
        {
            var exportProvider = compositionServices.GetExportProvider();

            var connectionManager = exportProvider.GetExportedValue <IConnectionManager>();
            var loggedIn          = await connectionManager.IsLoggedIn();

            if (!loggedIn)
            {
                var dialogService = exportProvider.GetExportedValue <IDialogService>();
                var connection    = await dialogService.ShowLoginDialog();

                if (connection == null)
                {
                    return;
                }
            }

            var factory   = exportProvider.GetExportedValue <IViewViewModelFactory>();
            var viewModel = exportProvider.GetExportedValue <IRepositoryPublishViewModel>();

            var busy      = viewModel.WhenAnyValue(x => x.IsBusy).Subscribe(x => IsBusy = x);
            var completed = viewModel.PublishRepository
                            .Where(x => x == ProgressState.Success)
                            .Subscribe(_ =>
            {
                var teamExplorer = ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                teamExplorer?.NavigateToPage(new Guid(TeamExplorerPageIds.Home), null);
            });

            var view = factory.CreateView <IRepositoryPublishViewModel>();

            view.DataContext = viewModel;

            Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(
                x => view.Unloaded += x,
                x => view.Unloaded -= x)
            .Take(1)
            .Subscribe(_ =>
            {
                busy.Dispose();
                completed.Dispose();
            });

            SectionContent = view;
        }