Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit b4e809d

Browse files
jcansdaleStanleyGoldman
authored andcommitted
Locate the DefaultExportProvider using MEF
1 parent fe9b3f2 commit b4e809d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/GitHub.VisualStudio.16/Sync/PublishSection.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.ComponentModel;
3-
using System.ComponentModel.Composition.Hosting;
3+
using System.ComponentModel.Composition;
44
using System.Linq;
55
using System.Reactive.Linq;
66
using System.Windows;
@@ -10,8 +10,10 @@
1010
using GitHub.ViewModels.TeamExplorer;
1111
using GitHub.VisualStudio;
1212
using Microsoft.TeamFoundation.Controls;
13-
using Microsoft.VisualStudio.ComponentModelHost;
13+
using Microsoft.VisualStudio.Composition;
1414
using ReactiveUI;
15+
using ExportProvider = System.ComponentModel.Composition.Hosting.ExportProvider;
16+
1517

1618
namespace Microsoft.TeamExplorerSample.Sync
1719
{
@@ -21,18 +23,19 @@ namespace Microsoft.TeamExplorerSample.Sync
2123
[TeamExplorerSection(SectionId, TeamExplorerPageIds.GitCommits, Priority)]
2224
public class PublishSection : TeamExplorerBaseSection
2325
{
26+
readonly ExportProvider defaultExportProvider;
27+
2428
public const string SectionId = "35B18474-005D-4A2A-9CCF-FFFFEB60F1F5";
2529
public const int Priority = 4;
2630

2731
readonly Guid PushToRemoteSectionId = new Guid("99ADF41C-0022-4C03-B3C2-05047A3F6C2C");
2832
readonly Guid GitHubPublishSectionId = new Guid("92655B52-360D-4BF5-95C5-D9E9E596AC76");
29-
30-
/// <summary>
31-
/// Constructor.
32-
/// </summary>
33-
public PublishSection()
34-
: base()
33+
34+
[ImportingConstructor]
35+
public PublishSection(VisualStudio.Composition.ExportProvider defaultExportProvider)
3536
{
37+
this.defaultExportProvider = defaultExportProvider.AsExportProvider();
38+
3639
this.Title = "Publish to GitHub";
3740
this.IsExpanded = true;
3841
this.IsBusy = false;
@@ -111,10 +114,8 @@ void ShowPublishDialog()
111114

112115
ExportProvider GetExportProvider()
113116
{
114-
var componentModel = ServiceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
115-
Assumes.Present(componentModel);
116117
var compositionServices = new CompositionServices();
117-
var compositionContainer = compositionServices.CreateVisualStudioCompositionContainer(componentModel.DefaultExportProvider);
118+
var compositionContainer = compositionServices.CreateVisualStudioCompositionContainer(defaultExportProvider);
118119
return compositionContainer;
119120
}
120121

0 commit comments

Comments
 (0)