11using System ;
22using System . ComponentModel ;
3- using System . ComponentModel . Composition . Hosting ;
3+ using System . ComponentModel . Composition ;
44using System . Linq ;
55using System . Reactive . Linq ;
66using System . Windows ;
1010using GitHub . ViewModels . TeamExplorer ;
1111using GitHub . VisualStudio ;
1212using Microsoft . TeamFoundation . Controls ;
13- using Microsoft . VisualStudio . ComponentModelHost ;
13+ using Microsoft . VisualStudio . Composition ;
1414using ReactiveUI ;
15+ using ExportProvider = System . ComponentModel . Composition . Hosting . ExportProvider ;
16+
1517
1618namespace 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