|
18 | 18 | using Microsoft.VisualStudio.Threading; |
19 | 19 | using ReactiveUI; |
20 | 20 | using Task = System.Threading.Tasks.Task; |
| 21 | +using Microsoft.VisualStudio.Shell; |
| 22 | +using System.ComponentModel.Composition.Hosting; |
21 | 23 |
|
22 | 24 | namespace Microsoft.TeamExplorerSample.Sync |
23 | 25 | { |
@@ -80,27 +82,15 @@ public override void Initialize(object sender, SectionInitializeEventArgs e) |
80 | 82 | } |
81 | 83 | } |
82 | 84 |
|
83 | | - PublishToGitHub = new RelayCommand(o => DoPublishToGitHub().Forget()); |
| 85 | + PublishToGitHub = new RelayCommand(o => ShowPublishDialog()); |
84 | 86 | } |
85 | 87 |
|
86 | | - async Task DoPublishToGitHub() |
| 88 | + void ShowPublishDialog() |
87 | 89 | { |
88 | | - var componentModel = ServiceProvider.GetService(typeof(SComponentModel)) as IComponentModel; |
89 | | - ShowPublishDialog(componentModel); |
90 | | - } |
91 | | - |
92 | | - void ShowPublishDialog(IComponentModel componentModel) |
93 | | - { |
94 | | - /* |
95 | | - var factory = ServiceProvider.GetService<IViewViewModelFactory>(); |
96 | | - var viewModel = ServiceProvider.GetService<IRepositoryPublishViewModel>(); |
97 | | - */ |
| 90 | + var exportProvide = GetExportProvider(); |
98 | 91 |
|
99 | | - var compositionServices = new CompositionServices(); |
100 | | - var compositionContainer = compositionServices.CreateVisualStudioCompositionContainer(componentModel.DefaultExportProvider); |
101 | | - |
102 | | - var factory = compositionContainer.GetExportedValue<IViewViewModelFactory>(); |
103 | | - var viewModel = compositionContainer.GetExportedValue<IRepositoryPublishViewModel>(); |
| 92 | + var factory = exportProvide.GetExportedValue<IViewViewModelFactory>(); |
| 93 | + var viewModel = exportProvide.GetExportedValue<IRepositoryPublishViewModel>(); |
104 | 94 |
|
105 | 95 | var busy = viewModel.WhenAnyValue(x => x.IsBusy).Subscribe(x => IsBusy = x); |
106 | 96 |
|
@@ -138,6 +128,15 @@ void ShowPublishDialog(IComponentModel componentModel) |
138 | 128 | */ |
139 | 129 | } |
140 | 130 |
|
| 131 | + ExportProvider GetExportProvider() |
| 132 | + { |
| 133 | + var componentModel = ServiceProvider.GetService(typeof(SComponentModel)) as IComponentModel; |
| 134 | + Assumes.Present(componentModel); |
| 135 | + var compositionServices = new CompositionServices(); |
| 136 | + var compositionContainer = compositionServices.CreateVisualStudioCompositionContainer(componentModel.DefaultExportProvider); |
| 137 | + return compositionContainer; |
| 138 | + } |
| 139 | + |
141 | 140 | void HandleCreatedRepo(LocalRepositoryModel newrepo) |
142 | 141 | { |
143 | 142 | var msg = String.Format(CultureInfo.CurrentCulture, Constants.Notification_RepoCreated, newrepo.Name, newrepo.CloneUrl); |
|
0 commit comments